微软等数据结构+算法面试100题(12)--快速排序
来源:互联网 发布:死亡岛低配置优化补丁 编辑:程序博客网 时间:2024/04/30 11:37
/*3.快速排序(东软喜欢考类似的算法填空题,又如堆排序的算法等)*/int Parition(int *p,int low,int high){int pivotkey=p[low];while(low<high){while((low<high)&&(p[high]>=pivotkey))//这里相等不能丢掉high--;p[low]=p[high];while((low<high)&&(p[low]<=pivotkey))low++;p[high]=p[low];}p[low]=pivotkey;return low;}void QuickSort(int *p,int low,int high){if(low>=high)return;int pivot=Parition(p,low,high);QuickSort(p,low,pivot-1);QuickSort(p,pivot+1,high);}
void QuickSortTest(){int p[]={10,0,15,12,-10,-5,9,2,8,6,4,20,19,6,8,7};int len=sizeof(p)/sizeof(int);cout<<"the array : ";ShowArray(p,len);cout<<"after sort : ";QuickSort(p,0,len-1);ShowArray(p,len);}
- 微软等数据结构+算法面试100题(12)--快速排序
- 微软等数据结构+算法面试100题
- 微软等数据结构+算法面试 100 题
- 微软等数据结构+算法面试100题
- 微软等数据结构+算法面试100题(19)--链表
- 微软等数据结构+算法面试100题(43)-- 把二元查找树转变成排序的双向链表
- 微软等数据结构+算法面试100题(47)-- 微软三道面试题
- 微软等数据结构+算法面试100题(48)-- 微软十五道面试题
- 微软等数据结构与算法面试100题 第一题
- 微软等数据结构与算法面试100题 第二题
- 微软等数据结构与算法面试100题 第三题
- 微软等数据结构与算法面试100题 第四题
- 微软等数据结构与算法面试100题 第五题
- 微软等数据结构与算法面试100题 第六题
- 微软等数据结构与算法面试100题 第七题
- 微软等数据结构与算法面试100题 第九题
- 微软等数据结构与算法面试100题第十题
- 微软等数据结构与算法面试100题第十一题
- javascript日期处理-通过一个字符串的日期得到所在周、上周及下周的第一天和最后一天
- 微软等数据结构+算法面试100题(10)--三道面试题
- 内核定时器的使用
- 微软等数据结构+算法面试100题(11)--压缩字符串
- STUN协议,探测NAT类型
- 微软等数据结构+算法面试100题(12)--快速排序
- URL特殊字符需转义
- 微软等数据结构+算法面试100题(13)--金山笔试题
- Ubuntu 11.04 DVD AMD64 hello.ko ——how to write ko.
- asp.net中为TextBox Web服务器控件添加OnClick事件
- C#与C++和C语言之间数据类型的对应
- 微软等数据结构+算法面试100题(14)--实现strstr 功能
- 字典树(Trie)
- Boost下载安装编译配置使用指南(含Windows和Linux)