- 2020-06-23 05:33
*views 4*- Data Structure and Algorithms

Sorting algorithm can be divided into internal sorting and external sorting , Internal sorting is the sorting of data records in memory , The external sorting is due to the large data , Cannot hold all sorting records at one time , External storage needs to be accessed during sorting .

Basic ideas adopted for various internal sorting ( strategy ) It can be divided into ： Insert sort , Exchange sort , Select sort , Merge sort and cardinality sort , Their basic strategy is ：

1, Insert sort

： One record in an unordered sequence in turn , Inserts the size of the key value into the appropriate position of a sequenced subsequence , Until all records are inserted . Specific methods include ： Direct insertion , Table insert ,2- Road insertion and shell sort .

2, Exchange sort

： For records in the sequence of records to be sorted , Keywords of pairwise comparison records , And exchange the two records in reverse order , Until there is no even pair of records in reverse order in the whole sequence . Specific methods include ： Bubble sorting , Quick sort .

3, Select sort ： Continuously select the record with the smallest keyword from the record sequence to be sorted , Placed at the end of a sequenced sequence , Until all records are selected . Specific methods include ： Simple selection sorting , Heap sort .

4, Merge sort ： utilize “ Merge ” Technology continuously merges the ordered subsequences in the ordered record sequence , Until combined into an ordered sequence .

5, Cardinality sort

： Composition of keywords by records to be sorted (“ position ”) From low to high ( Or from high to low ) conduct . Each time by record key “ position ” The value of allocates all records to the corresponding bucket , Then collect the records according to the number of barrels , Finally, we get an ordered sequence .

Common internal sorting algorithms include ： Insert sort (insertion sorting), Shell Sort (Shell Sort), Select sort (Selection

sort), Heap sort (Heapsort), Bubble sorting (Bubble Sort), Quick sort (quick sort), Merge sort (Merge

sort), Cardinality sort (Radix sort).

The following figure lists the time complexity of various sorting algorithms , Space complexity and stability . among , The spatial complexity only lists the average complexity , Because the time complexity of Hill sort depends on increment function , So we can't give its time complexity accurately .

Technology

- Java426 articles
- Python242 articles
- Vue127 articles
- Linux119 articles
- MySQL100 articles
- javascript77 articles
- SpringBoot72 articles
- C++68 articles
- more...

Daily Recommendation

©2019-2020 Toolsou All rights reserved,

java Four functional interfaces （ a key , simple ）os Simple use of module Browser kernel （ understand ） Some East 14 Pay change 16 salary , Sincerity or routine ?HashMap Explain in detail It's unexpected Python Cherry tree （turtle The gorgeous style of Library ）html Writing about cherry trees , Writing about cherry trees