What are the choices to sort
What are the options for sorting? 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.
There are two kinds of selection sorting: simple selection sorting and heap sorting. Simple selection sorting is an intuitive sorting algorithm, while heap sorting is to generate a maximum heap of unordered sequences, swap the heap top element with the last element, generate the maximum heap of the remaining elements, exchange elements in turn and generate the maximum heap.
Select sort
Simple selection sort
Simple selection sorting (Simple Selection Sort) is an intuitive sorting algorithm, which selects the smallest element in the unsorted sequence to exchange with the first element of the sequence, then selects the smallest element in the remaining unsorted sequence to exchange with the second element of the sequence, and so on, and finally forms a sorted sequence from small to large.
Time complexity: O (N2)
Heap sort
The unordered sequence is generated into a maximum heap, the top element of the heap is swapped with the last element, the remaining elements are generated into the maximum heap, and the elements are exchanged in turn to generate the maximum heap.
Time complexity: O (NlogN) space complexity: O (1)
Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.