排序算法
复杂度
- 稳定性:
- 指待排序的序列中有两元素相等,排序之后它们的先后顺序不变.
- 也可以理解为一切皆在掌握中,元素的位置处在你在控制中.而不稳定算法有时就有点碰运气,随机的成分.
BubbleSort
1 | void BubbleSort(vector<int>& vec, int l, int r){ |
SelectionSort
1 | void SelectionSort(vector<int>& vec, int n){ |
InsertionSort
1 | void InsertionSort(vector<int>& vec, int n){ |
ShellSort
1 | void ShellSort(vector<int>& nums) { |
MergeSort
1 | void Merge(vector<int>& vec, int l, int mid, int r){ |
QuickSort
1 | void QuickSort(vector<int>&nums, int l, int r) { |
HeapSort
1 | void heapify(vector<int>& vec, int i, int n){ |
BucketSort
1 | //设置10个桶 |
RadixSort
1 | int get_max(vector<int>& vec, int n) |
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Escapeey`Blog!
评论