排序算法
冒泡排序(bubble sort)
优化后时间复杂度是O(n)
1 | do |
选择排序(selection sort)
1 | repeat (numOfElements -1) times |
插入排序(insertion sort)
1 | mark first element as sorted |
归并排序(merge sort)
1 | split each element into partitions of size 1 |
快速排序(quick sort)
1 | for each (unsorted) partition |
随机快速排序在数据量大时优于快速排序
计数排序(countion sort)
1 | create key (counting) array |
基数排序(radix sort)
1 | create 10 buckets (queues) for each digit (0 to 9) |