Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What sort algorithms are there?

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

What sort algorithms are there? Many novices are not very clear about this. In order to help you solve this problem, the following editor will explain it in detail. People with this need can come and learn. I hope you can gain something.

1. Insert sort-directly insert sort (Straight Insertion Sort)

Basic ideas:

Insert a record into a sorted ordered table to get a new ordered table with an increment of 1 in the number of records. That is, the first record of the sequence is regarded as an ordered subsequence, and then inserted one by one from the second record until the whole sequence is ordered.

Key point: set up sentinels to temporarily store and judge the boundaries of the array.

Direct insertion sorting example:

If you encounter one that is equal to the insert element, the insert element places the element you want to insert after the equivalent element. Therefore, the order of the equal elements has not changed, and the order out of the original unordered sequence is the ordered order, so the insertion sort is stable.

Implementation of the algorithm:

Void print (int a [], int n, int I) {cout

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report