随机快速排序
2009-10-12 20:25
120 查看
#include <stdlib.h>
#include <time.h>
#include <stdio.h>
typedef int Record;
void QuickSort (Record r[],int s,int t);
void QuickSort (Record r[],int s,int t)
...{
int low=s;
int high=t;
Record pivot;
...{
int t,tn;
srand(time(NULL));
tn=rand()%(high-low+1)+low;
t=r[low];
r[low]=r[tn];
r[tn]=t;
}
pivot=r[s];
while (low<high)...{
while (low<high && r[high]>=pivot)
high--;
if (low<high) r[low]=r[high];
while (low<high && r[low]<=pivot)
low++;
if (low<high) r[high]=r[low];
}
r[low]=pivot;
if (s<low) QuickSort(r,s,low-1);
if (t>high) QuickSort(r,high+1,t);
}
相关文章推荐
- C/C++实现快速排序和随机快速排序
- 快速排序 普通和随机版本
- 算法导论 第七章快速排序与随机快速排序
- 算法导论笔记之----随机快速排序
- 分治法_随机快速排序
- 快速排序随机初始基准数
- 快速排序/随机快速排序
- 快速排序和随机快速排序
- 随机快速排序
- 算法导论-4.随机快速排序与线性时间排序
- 算法初级02——荷兰国旗问题、随机快速排序、堆排序、桶排序、相邻两数的最大差值问题、工程中的综合排序算法
- python版本的随机快速排序
- 算法入门--快速排序2(随机产生分割主元素)
- java实现快速排序和随机快速排序
- 算法导论 第七章 随机快速排序
- 随机快速排序的java代码
- java 快速排序随机选择key
- 快速排序 与 随机快速排序 算法分析
- 非随机快速排序C语言实现
- 随机快速排序(内嵌插入排)