帮我找一份排序算法性能分析,谢谢

r11222 2010-08-08 12:50:33
分析各个排序算法,在各个情况下的性能分析

基本有序,乱序,倒序,等情况的性能差别,最好完整点的,谢谢各位!!

想做一个整理。
...全文
131 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
r11222 2010-08-09
  • 打赏
  • 举报
回复
但我想要一份理论的结果, 有人有吗??谢谢了
bida33755 2010-08-08
  • 打赏
  • 举报
回复
同求!
刚才google "sorting algorithms comparison"找到这个,看起来似乎不错!

Comparison of Sorting Algorithms

The following table summarizes the basic strategies used in various sorting
algorithms, and lists the algorithms that use these strategies.

Comparison-Based Sorting Methods
Transposition (exchange adjacent values)
Bubble Sort **
Priority Queue (select largest value)
Selection Sort **
Heap Sort
Insert and Keep Sorted
Insertion Sort **
Tree Sort
Diminishing Increment
Shell Sort
Divide & Conquer
Quicksort
Merge Sort
Address-Calculation Sorting Methods
Radix Sort

Algorithms marked with ** have been discussed in class. Implementations of
some of these algorithms are available on the Pascal Page.

The diagrams below may help you develop an intuitive sense of how the
algorithms work. The vertical axis is the position within the array and the
horizontal axis is time. Values within the array are represented by small
squares with differing brightness. The goal of the algorithm is to sort the
values from darkest to lightest. In each diagram, the input array is
represented by a vertical column on the left, with an random assortment of
brightess values. (Click on an image to see a larger version.)

[bubble sort] [selection sort] [insertion sort] [quicksort]
bubble selection insertion quicksort

Bubble Sort exchanges adjacent values so lighter ones "bubble up" towards
the top, and darker ones "sink down" towards the bottom. Selection Sort
minimizes exchanges by scanning the unsorted portion to find the largest
remaining value on each iteration. Insertion Sort is familiar to anyone who
plays cards. It works by taking the next value from the unsorted portion
and inserting it into the already sorted portion of the array. Of these
three, Insertion Sort is the most efficient, on average, but Selection Sort
is preferred when the records are large. Bubble Sort is never preferred.
(Quicksort will be discussed later in this course.)

The following table summarizes what we have learned about the relative
efficiency of various sorting algorithms.

Bubble Sort (version discussed in class)
best case:
about N comparisons, 0 exchanges,
(input already sorted)
worst case:
about N^2 comparisons, N^2 exchanges,
(input sorted in reverse order)
average case:
quite close to worst case (difficult to analyze)
notes:
Very inefficient and should never be used. Uses an
excessive and unnecessary number of exchanges.

Bubble Sort (version in textbook)
best case:
about N^2/2 comparisons, 0 exchanges,
(input already sorted)
worst, average cases:
about N^2/2 comparisons, N^2/2 exchanges

Selection Sort
all cases:
about N^2/2 comparisons, N exchanges
notes:
minimizes the number of exchanges;
execution time quite insensitive to original ordering
of input data.

Insertion Sort
best case:
about N comparisons, 0 moves,
(input already sorted)
worst case:
about N^2/2 comparisons, N^2/2 moves,
(input sorted in reverse order)
average case:
about N^2/4 comparisons, N^2/4 moves
notes:
very efficient when input is "almost sorted";
moving a record is about half the work of exchanging
two records, so average case is equivalent to roughly
N^2/8 exchanges.




original site:http://www.gamedev.net/reference/articles/article301.asp
jackyjkchen 2010-08-08
  • 打赏
  • 举报
回复
自己测试比较靠谱,不一样的机器结果不同,有些甚至违反理论

综合性能上优化过的快速排序最快,希尔、堆、归并等次之但可接受,插入、选择、冒泡非常慢,不能用于大数据,bogo、stooreg没有实用价值

在排序字节串的条件下,鸽巢、计数是最快的,基数次之,但都有额外空间消耗。

哪怕是维基百科、数据结构与算法等书上的排序对比,也很那做到全面和准确
cattycat 2010-08-08
  • 打赏
  • 举报
回复
这个你自己分析吧,你好好看算法导论上的分析就能有结果了。
FancyMouse 2010-08-08
  • 打赏
  • 举报
回复
bead sort

69,371

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧