![](https://img-blog.csdnimg.cn/20201014180756916.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
C++
SL Zhong
111
展开
-
堆排序
复杂度和稳定性 时间复杂度:最好、最坏、平均:O(N*ln(N)) 稳定性:不稳定 CPP实现: #include <vector> #include <time.h> #include <stdlib.h> using namespace std; void make_heap_max(vector<int>& v, int start, ...原创 2020-01-19 01:33:06 · 56 阅读 · 0 评论 -
希尔排序
复杂度和稳定性 时间复杂度:平均O(Nln(N)),最好O(N),最差O(NN) 空间复杂度:O(1) 稳定性:不稳定 CPP实现 #include <vector> #include <stdlib.h> #include <time.h> using namespace std; void shell_sort(vector<int>& ...原创 2020-01-18 00:38:20 · 65 阅读 · 0 评论 -
插入排序和选择排序
插入排序 一、复杂度和稳定性 时间复杂度:最坏和平均:O(N*N),最好O(N) 空间复杂度:O(1) 稳定性:稳定 二、CPP实现 #include <vector> #include <stdlib.h> #include <time.h> using namespace std; void insert_sort(vector<int>&...原创 2020-01-17 02:48:57 · 80 阅读 · 0 评论 -
归并排序
一、复杂度和稳定性 时间复杂度:平均,最好,最坏:O(N*ln(N)) 空间复杂度:O(N) 稳定性:稳定 二、CPP实现 #include <vector> using namespace std; void merge(vector<int>& src, vector<int>& tmp, int s, int e, int m) { in...原创 2020-01-15 02:21:13 · 75 阅读 · 0 评论 -
placement new
内存池中会“释放”内存 所谓内存中的释放,实际只是内存复用,并没有把内存还给操作系统 所以释放的时候需要调用析构函数,再次使用的时候需要调用构造函数 在没有使用内存池的时候构造只需要new Object就可以了,但是在使用内存池的时候应该咋办呢 用placement new 有一个类: class Object { public: Object(){}; ... }; placement n...原创 2020-01-13 23:57:44 · 65 阅读 · 0 评论