Sorting Notes
Sorting puts elements of a list in a certain order, which is critical in computer science algorithms in terms of efficiency.
It is easier and faster to locate items in a sorted list than unsorted.
There are many sorting algorithms I encountered since I started teaching myself to code. Here are a little reference notes of common sorting algorithms.
Quick Sort
O(N Log N)
|
|
Quick Select
O (K Log N)
Quick select is a modification of quick sort.
Merge Sort
O(N Log N)
|
|
Bucket Sort
O(N + k)
- bucketSort(arr[], n)
- Create n empty buckets (Or lists).
- Do following for every array element arr[i].
- Insert arr[i] into bucket[n*array[i]]
- Sort individual buckets using insertion sort.
- Concatenate all sorted buckets.
|
|
Radix Sort
O(N * k)
There more challenging sorting puzzles in LeetCode:
Questions
- [区间K大数查询(求解方法总结](https://blog.csdn.net/iwbfaith/article/details/58589853)