
排序
CCSUZB
吾生也有涯,而知也无涯
展开
-
归并排序
#include <iostream> #include <algorithm> using namespace std;void merge_sort(int *A, int x, int y, int *T) { if (y - x > 1) { int m = x + (y - x) / 2; int p = x, q = m, i = x;原创 2017-06-24 19:40:15 · 202 阅读 · 0 评论 -
选择排序
原理图#include <iostream> #include <algorithm> using namespace std;int main() { int arr[6] = { 6,5,4,3,2,1 }; int min, temp; for (int i = 0; i < 6; i++) { min = i; for (in原创 2017-06-26 20:35:31 · 222 阅读 · 0 评论 -
Uva10305-拓扑排序
题目链接采用书上的DFS进行排序,书上遗留问题说为什么在访问一个节点后把它加到当前拓扑排序的首部原因是当进行递归的时候采用的栈而栈时先进后出的结构。#include <iostream> #include <cstdio> #include <cstring> using namespace std;const int maxn = 500; int n, m, a, t, b; int G[max原创 2017-07-07 20:23:50 · 382 阅读 · 0 评论 -
排序总结
前言 算法(第四版)第二章排序部分的代码实现以及简单总结 所需要用到的StdIn和StdOut以及部分方法代码 private static boolean less(Comparable v, Comparable w) //比较大小 { return v.compareTo(w) < 0; } private static ...原创 2018-05-10 20:01:29 · 178 阅读 · 0 评论