sorting algorithms
来源:互联网 发布:ubuntu安装包放在哪里 编辑:程序博客网 时间:2024/06/05 05:39
- from http://www.concentric.net/~ttwang/sort/sort.htm
Bubble Sort
- Exchange two adjacent elements if they are out of order. Repeat untilarray is sorted. This is a slow algorithm.
- Selection Sort
- Find the largest element in the array, and put it in the proper place.Repeat until array is sorted. This is also slow.
- Insertion Sort
- Scan successive elements for out of order item, then insert the itemin the proper place. Sort small array fast, big array very slowly.
- Quicksort
- Partition array into two segments. The first segment all elements areless than or equal to the pivot value. The second segment all elements aregreater or equal to the pivot value. Sort the two segments recursively.Quicksort is fastest on average, but sometimes unbalanced partitions canlead to very slow sorting.
- Mergesort
- Start from two sorted runs of length 1, merge into a single run of twicethe length. Repeat until a single sorted run is left. Mergesort needsN/2 extra buffer. Performance is second place on average, withquite good speed on nearly sorted array. Mergesort is stable in thattwo elements that are equally ranked in the array will not have their relativepositions flipped.
- Heapsort
- Form a tree with parent of the tree being larger than its children.Remove the parent from the tree successively. On average, Heapsort isthird place in speed. Heapsort does not need extra buffer, and performanceis not sensitive to initial distributions.
- Shellsort
- Sort every Nth element in an array using insertion sort. Repeat usingsmaller N values, until N = 1. On average, Shellsort is fourth place inspeed. Shellsort may sort some distributions slowly.
- Combo Sort
- Sorting algorithms can be mixed and matched to yield the desiredproperties. We want fast average performance, good worst case performance,and no large extra storage requirement. We can achieve the goal by startingwith the Quicksort (fastest on average). We modify Quicksort by sortingsmall partitions by using Insertion Sort (best with small partition). Ifwe detect two partitions are badly balanced, we sort the larger partitionby Heapsort (good worst case performance). Of course we cannot undo thebad partitions, but we can stop the possible degenerate case from continuingto generate bad partitions.
- Sorting Algorithms
- sorting algorithms
- Sorting Algorithms
- Sorting Algorithms ------[Insertion Sort]
- Sorting Algorithms ------ [MergeSort]
- Sorting Algorithms ------ [QuickSort]
- Sorting algorithms revisited
- Sorting Algorithms Review
- Sorting Algorithms Part1
- introduction to algorithms sorting lesson_3 shell sorting
- introduction to algorithms sorting lesson_4 quick sorting
- introduction to algorithms sorting lesson 2 merge sorting
- introduction to algorithms sorting lesson_5 Heap sorting(堆排序)
- C#数据结构和算法 [Basic Sorting Algorithms]
- STL之排序算法Sorting Algorithms
- introduction to algorithms sorting lesson 1 insertion
- Java Sorting Algorithms(Java排序算法)
- 排序算法学习笔记(sorting algorithms)
- 不准离婚的六个国家
- ReceiveMail.java
- jbpm4.0+tomcat6.0出现的异常:java.lang.LinkageError
- 蓝筹
- oprofile 使用之三(注意事项)
- sorting algorithms
- IBM
- 验证码
- ao接口通过经纬度求两点距离
- 【嵌入式Linux学习七步曲之第五篇 Linux内核及驱动编程】Linux内核抢占实现机制分析
- ZwSystemDebugControl函数列举系统PCI设备ID
- VxWorks中logMsg与printf的区别
- android中的左右滑屏实现By ViewPager
- 豆瓣书友Pro:这个小三比老婆#豆瓣购书单#好?