07 2019 档案
摘要:1 #include 2 3 void sort(int sz[], int low, int high) 4 { 5 int p = sz[low]; // 模仿快速排序,时间复杂度为o(n), 空间复杂度o(1) 6 while (low < high) 7 { 8 while (low < high && (sz[high] % ...
阅读全文
摘要:1 /** 2 * 问题描述:一只青蛙一次可以跳上1级台阶,也可以跳上2级。求该青蛙跳上一个n级的台阶总共需要多少种跳法。 3 */ 4 #include 5 6 // 递归算法 7 int faci(int n) 8 { 9 if (n == 0) 10 return 0; 11 else if (n == 1) 12 ...
阅读全文
摘要:1 #include 2 #include 3 4 /** 5 * 【数据结构 C描述】有两个整数集合 A 和 B 分别用两个线性表 LA 和 LB 表示, 6 * 求:一个新的集合C=A∪B,C仍然为纯集合,线性表采用链式存储方式。 7 * 注:本算法中LA, LB为递增有序情况,无序的话可以考虑暴力 8 * 此情况下复杂度为o(m+n), m, ...
阅读全文
摘要:1 #include 2 /**** 3 * 此算法为满二叉树通过先序遍历数组获得后序遍历数组 4 ***/ 5 // a[]为pre数组,b[]为post数组 6 void get_lrn_by_nlr(char a[], int a_left, int a_right, char b[], int b_left, int b_right) 7 { 8 if (...
阅读全文