05 2016 档案
摘要://maximum and minimum 暴力遍历 O(n) //i-th element dicide and conquer random_selected_partition k(all the element samller than value[k] put left of value[
阅读全文
摘要://intput array A,output array result. count array count . //all the elements is in te range of 0~k. //if k=O(n),the complexity is Θ(n) //counting sort
阅读全文
摘要://max_heap heap_maximum:return A[1] O(1); Extract_Heap_maximum:swap(A[1],A[heap.size]) adjust up to down from A[1] to hold the max_heap character O(lg
阅读全文
摘要://用满二叉树存储,从n/2处开始递归向上调整(n/2后均为叶子节点,无需调整)使得根最大 //满二叉树顺序存储,左子2i,右子2i+1; #include<stdio.h>#include<stdlib.h>#include<time.h>#define ARRAY_SIZE 1000#defin
阅读全文
摘要://the first k elements interviewed and rejected, //for the latter n-k elements ,if value >max,return value, else return n'elements. #include<stdio.h>#
阅读全文
摘要:T(n)=aT(n/b)+f(n); where we can interpret n/b to mean either floor(b/n) or ceil(b/n), Then T (n) has the following asymptotic bounds: 1. If f (n)= O(n
阅读全文
摘要:#include<stdio.h>#include<stdlib.h>#include<time.h>#define ARRAY_SIZE 1000int buf [ARRAY_SIZE];int main(){ srand((unsigned int )time(0)); int i,j,n; w
阅读全文
摘要:#include<stdio.h>#include<string.h>#include<stdlib.h>#include<time.h>#define ARRAY_SIZE 1000int buf[ARRAY_SIZE];int main(){ int i,j,n; srand((unsigned
阅读全文
摘要:macro is typeless and execute faster than funtion ,becaus of the overhead of calling and returnning of function,but macro will increase the size of pr
阅读全文