Sorting Algorithm summary, Sorting Algorithm
Note:
Insert sort: 1: insert sort O directly (n ^ 2)
2: semi-inserted sorting O (n ^ 2)
3: Hill sorting O (n multiplied by the log base 2, the logarithm of n)
Space complexity is O (1)
Exchange sort: 1: bubble sort O (n ^ 2), space complexity O (1)
2: Fast sorting of O (n multiplied by the log base 2, the logarithm of n), space complexity O (log base 2, the logarithm of n)
Select class sorting: 1: Simple selection of sorting O (n ^ 2), Space O (1)
2: heap sorting O (n multiplied by the log base 2, the logarithm of n), space complexity O (1)
Two-way Merge Sorting: O (n multiplied by the log base 2, the logarithm of n), space complexity O (n)
Base sorting: time O (d (n + rd) d: Number of keywords, n: number of elements, rd: value range of keywords
Space O (rd)
Note: For value sorting, the base sorting can only be performed from low to high, and can be ordered, (high to low, no)
1: on average, (fast, Greek, returning, heap)-> time complexity O (n multiplied by the log base by 2, the logarithm of n)
Other O (n ^ 2), base sort O (d (n + rd) d: Number of keywords, n: number of elements, rd: value range of keywords
2: spatial complexity, fast-> O (log base 2, logarithm of n)
-> O (n)
Base-> O (rd)
Others-> O (1)
3: time complexity. Direct insertion and bubbling are easy (ordered) to change to O (n)
4: unstable sorting-> (fast, Greek, select, heap)
5: after sorting, an element can reach the final position: a switching class (bubble, fast)
B. Select a class (select, heap)
6: sorting. The number of element comparisons is irrelevant to the original sequence. a selects sorting.
B-semi-insert sorting
In addition, the time complexity (merging, heap, and base) is irrelevant to the start time.
7: The number of sorted orders (all numbers are processed once for one trip) is related to the original sequence ---> exchange class: Run/fast