
排序算法
文章平均质量分 73
小小小小葱
这个作者很懒,什么都没留下…
展开
-
快速排序
快速排序是一种分治的排序算法,每次从数组中选一个数作为主元,使左边的一部分都小于等于它,右边的一部分都大于等于它,然后再递归把左右两边分别排序,一般效率是O(nlgn)。 一种方法是每次选择排序区间的最后一个元素作为主元。 void Qsort(int x,int y) //[x,y]是排序区间,a[y]是主元 { if(x>=y) return; int t,i=x-1,原创 2013-07-31 11:21:06 · 652 阅读 · 0 评论 -
归并排序求逆序对数
UPC OJ Problem H: Seating Chart Description Bilbo's birthday is coming up, and Frodo andSam are in charge of all the party planning! Theyhave invited all the hobbits of Middle Earth tothe party,原创 2013-05-28 11:33:00 · 1051 阅读 · 0 评论