快速排序
来源:互联网 发布:数据归一化后的值 编辑:程序博客网 时间:2024/06/07 14:40
在最优的情况下,快速排序算法的时间复杂度为O(nlongn)
在最坏的情况下,快速排序算法的时间复杂度为O(n*n)
平均的时间复杂度为O(nlongn)
在最优的情况下,快速排序算法的时间复杂度为O(longn)
在最坏的情况下,快速排序算法的时间复杂度为O(n)
平均的时间复杂度为O(longn)
快速排序是一种不稳定的排序算法
#include<iostream>using namespace std;int Partition(int *num,int low,int high){int pivot=num[low];while(low<high){while(low<high && num[high]>=pivot)high--;num[low]=num[high];while(low<high && num[low]<=pivot)low++;num[high]=num[low];}num[low]=pivot;return low;}//快速排序void QuitSort(int *num, int low, int high){if(low<high){int pivot=Partition(num,low,high);//划分 QuitSort(num, low, pivot-1);QuitSort(num, pivot+1, high);}} int main(){int num[10]={4,0,2,3,1,8,5,4,12,6};QuitSort(num,0,10);for(int i=0; i<10; i++)cout<<num[i]<<" ";cout<<endl;return 0;}
0 0
- 快速排序
- 快速排序
- 快速排序
- 快速排序!
- 快速排序
- 快速排序
- 快速排序
- 快速排序
- 快速排序
- 快速排序
- 快速排序
- 快速排序
- 快速排序
- 快速排序
- 快速排序
- 快速排序
- 快速排序
- 快速排序
- spark单机部署问题
- XML简介
- Github入门教程
- 利用随机数函数生成 6 个字符,依次拼接到“Words:”字符串的末尾, 并输出该字符串的长度,大写英文字母的个数。
- 窗口的子类化与超类化
- 快速排序
- LeetCode *** 228. Summary Ranges
- ACM
- 关于MFC中添加对话框类后类视图(class view)无显示
- STM32初学之Sys_Tick配置
- 基于sklearn的特征选择方法
- 扩展GCD
- 认识vim
- 如果链表可能有环,判断两个链表是否相交?