2013年8月17日

coursera review---algorithms,Stanford---03---master method

摘要: the master methodprovides a cookbook solution inasymptoticterms (usingBig O notation) forrecurrence relationsof types that occur in theanalysisof manydivide and conquer algorithmsthe following is the simplified expression:a = number of recursive calls,(>=1)b = input size shrink factor,(>1)d = 阅读全文

posted @ 2013-08-17 16:38 haoyancoder 阅读(384) 评论(0) 推荐(0)

coursera review---algorithms,Stanford---02---quick sort

摘要: the idea of quick sort is:choose a pivot(randomly or simply)partition the array into a[0,1,...,pivot-1],a[pivot],a[pivot+1,...,end] that all elements ina[0,1,...,pivot-1] = a[pivot]quick sorta[0,1,...,pivot-1]quick sorta[pivot+1,...,end] 1 void swap(int a[], int i, int j) { 2 int temp = a[i]; 3 ... 阅读全文

posted @ 2013-08-17 16:20 haoyancoder 阅读(248) 评论(0) 推荐(0)

big number multiplication---straightforward method---not Karatsuba

摘要: input: string a, string boutput : a string that denotes a times b 1 #include 2 3 string mul(const string & a, const string & b) { 4 int al = a.length(); 5 int bl = b.length(); 6 int *result = new int[al + bl]; 7 for (int i = 0; i = 0; i--) {17 if (result[i] >= 10) {18 ... 阅读全文

posted @ 2013-08-17 11:29 haoyancoder 阅读(184) 评论(0) 推荐(0)

导航