![](https://img-blog.csdnimg.cn/20201014180756923.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
十大排序
排序算法
想名字多费事
编程小白入驻
展开
-
桶排序(C++版)
#include <iostream>#include <vector>using namespace std;void print(vector<int>& nums){ for(auto a: nums){ cout<<a<<" "; } cout<<endl;}void bubbleSort(vector<int>& nums,int size){原创 2021-08-07 14:16:29 · 163 阅读 · 0 评论 -
归并排序(C++版)
//归并排序->先使子序列有序,再使子序列段间有序//时间复杂度都是nlogn 空间复杂度是O(n)#include <iostream>#include <vector>using namespace std;void print(vector<int>& nums){ for(auto a: nums){ cout<<a<<" "; } cout<<endl;}原创 2021-08-07 10:49:26 · 60 阅读 · 0 评论 -
堆排序(C++版)
//堆排序->完全二叉树//时间复杂度都是nlogn 空间复杂度是O(n)#include <iostream>#include <vector>using namespace std;void print(vector<int>& nums){ for(auto a: nums){ cout<<a<<" "; } cout<<endl;}//对每个节点做heap原创 2021-08-07 10:03:09 · 79 阅读 · 0 评论 -
快速排序(C++版)
#include <iostream>#include <vector>using namespace std;void quickSort(vector<int>& nums,int begin,int end){ if(begin>=end) return; int left=begin,right=end; int temp=nums[left];//注意!!! while(left<right)原创 2021-08-07 09:49:45 · 52 阅读 · 0 评论 -
希尔排序(C++版)
#include <iostream>#include <vector>using namespace std;void print(vector<int>& nums){ for(auto a: nums){ cout<<a<<" "; } cout<<endl;}//希尔排序的思想是采用插入排序的方法,//先让数组中任意间隔为 h 的元素有序,刚开始 h 的大小可以是原创 2021-08-06 23:54:03 · 111 阅读 · 1 评论 -
选择排序(C++版)
#include <iostream>#include <vector>using namespace std;void print(vector<int>& nums){ for(auto a: nums){ cout<<a<<" "; } cout<<endl;}//算法思想:在未排序序列中找到最小的元素,放到起始位置void selectSort(vector<i原创 2021-08-06 23:12:56 · 46 阅读 · 0 评论 -
插入排序(C++版)
#include <iostream>#include <vector>using namespace std;void print(vector<int>& nums){ for(auto a: nums){ cout<<a<<" "; } cout<<endl;}void insertSort(vector<int>& nums){ int size原创 2021-08-06 22:54:30 · 63 阅读 · 0 评论 -
冒泡排序(C++版)
#include <iostream>#include <vector>using namespace std;void print(vector<int>& nums){ for(auto a: nums){ cout<<a<<" "; } cout<<endl;}void bubbleSort(vector<int>& nums){ int size原创 2021-08-06 22:32:22 · 128 阅读 · 0 评论