![](https://img-blog.csdnimg.cn/20201014180756780.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
排序算法
文章平均质量分 63
等待一朵花开
C++
展开
-
快速排序
#include #include using namespace std;class Quick_sort{public: void quickSort(vector&s, int l, int r) { if (l < r) { int i = l, j = r, x = s[l]; whi原创 2016-09-19 10:50:19 · 203 阅读 · 0 评论 -
插入算法
#include #include using namespace std;void Insert_sort(vector&array, int length){ if (length==0) { return; } for (int i = 1; i < length;i++) { for (int j = i; j>原创 2016-09-19 10:51:47 · 249 阅读 · 0 评论 -
希尔排序
void shell_sort(vector&array, int n){ if (array.empty()) { return; } int j, gap; for (gap = n / 2; gap > 0;gap/=2) { for (j = gap; j < n;j++) {原创 2016-09-19 10:52:40 · 190 阅读 · 0 评论 -
归并排序
#include #include #define MAX 255int R[MAX];void Merge(int low,int m,int high){/* 将两个有序的子文件R[low..m)和R[m+1..high]归并成一个有序的 */ /* 子文件R[low..high] */ int i=low,j=m+1,p=0; /* 置初始值 */ int *R1; /*原创 2016-09-19 10:54:31 · 260 阅读 · 0 评论 -
归并排序
//堆排序的原理是遍历数组中的值,得到第一个值为最小,与最后一个值对换,再次遍历,第一个值与倒数第二个值替换,以此类推!#include #include #define MAX 255int R[MAX];void Heapify(int s,int m){ /*对R[1..n]进行堆调整,用temp做暂存单元 */ int j,temp; temp=R[s]; j=2*s;原创 2016-09-19 10:55:28 · 258 阅读 · 0 评论 -
排序链表
/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */class Solution {public: ListNode* fi原创 2016-09-19 10:56:44 · 296 阅读 · 0 评论 -
插入排序进行链表排序
/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */class Solution { public: ListNode *原创 2016-09-19 10:57:52 · 391 阅读 · 0 评论