摘要:
折半查找,这个非常简单 #include <iostream> using namespace std; // 折半查找 int Binary_search(int a[], int len, int key) { int low = 0, high = len - 1, mid; while (l 阅读全文
摘要:
堆排序: #include <iostream> using namespace std; // 建大根堆 void Heap_build(int a[], int root, int len) { int lchild = root*2 + 1; if (lchild < len) { int f 阅读全文
摘要:
#include <iostream> using namespace std; // 计算Next数组 void makeNext(const char p[], int next[]) { int q, k; // q是字符串下标,k是最大公共前缀 int m = strlen(p); next 阅读全文
摘要:
准备杭电复试,想着把数据结构相关的算法都自己写一遍,个人记录为主,带注释。 代码: #include <iostream> using namespace std; void quickSort(int a[], int low, int high) { int temp; //放枢轴的变量 int 阅读全文