| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 726 人关注过本帖
标题:Quick Sort
只看楼主 加入收藏
ronaldowsy
Rank: 1
等 级:新手上路
帖 子:68
专家分:0
注 册:2008-10-20
收藏
 问题点数:0 回复次数:1 
Quick Sort
Description
Quicksort is a well-known sorting algorithm developed by C. A. R. Hoare that, on average, makes Θ(n log n) comparisons to sort n items. However, in the worst case, it makes Θ(n2) comparisons. Typically, quicksort is significantly faster in practice than other Θ(n log n) algorithms, because its inner loop can be efficiently implemented on most architectures, and in most real-world data it is possible to make design choices which minimize the possibility of requiring quadratic time.

Quicksort sorts by employing a divide and conquer strategy to divide a list into two sub-lists.

The steps are:
1. Pick an element, called a pivot, from the list.
2. Reorder the list so that all elements which are less than the pivot come before the pivot and so that all elements greater than the pivot come after it (equal values can go either way). After this partitioning, the pivot is in its final position. This is called the partition operation.
3. Recursively sort the sub-list of lesser elements and the sub-list of greater elements.

The base case of the recursion are lists of size zero or one, which are always sorted. The algorithm always terminates because it puts at least one element in its final place on each iteration (the loop invariant).
图片附件: 游客没有浏览图片的权限,请 登录注册

 
Quicksort in action on a list of random numbers. The horizontal lines are pivot values.

Write a program to sort ascending int number by QuickSort ,n less than 50000.

Input :two lows, the first low is numbers , less and equal than 50000.
the second low is a set integer numbers

Output :a set integer numbers of sort ascending

Sample Input :
10
4 2 1 5 7 6 9 8 0 3

Sample Output :
0 1 2 3 4 5 6 7 8 9
搜索更多相关主题的帖子: Sort Quick 
2008-10-20 21:22
vfdff
Rank: 6Rank: 6
等 级:侠之大者
威 望:8
帖 子:2172
专家分:425
注 册:2005-7-15
收藏
得分:0 
这个图好帅,怎么设计的 ??

~~~~~~~~~~~~~~~好好学习~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2008-10-20 22:21
快速回复:Quick Sort
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.056448 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved