Algorithms
文章平均质量分 68
杰式囧诺
这个作者很懒,什么都没留下…
展开
-
The notes of Algorithms ---- Asymptotic Notation
O notation: O(g(n))={f(n): there exists consts c>0 no>0 such taht 0no} f(n)=O(g(n)) represents an anonymous function[f(n)] in that set[O(g(n))]. Ex1. f(n)=n^3+O(n^2) means there i原创 2013-04-01 20:57:50 · 771 阅读 · 0 评论 -
The notes of Algorithms ---- Data Structures ---- Hash Table
Table S holding n records. One record structure is like this: struct{ Key; Satellite data; } X, as a pointer, which point to one record. Operations - Insert(S,x); //S - Delete(S,x); //S原创 2013-04-15 16:11:31 · 998 阅读 · 0 评论 -
The Program of Algorithms ------- Diveide and Conquer ---- Randomized-Select
Randomized-Select: Question:Given n elements in array, find the i-th smallest element. Navie Algorithm: Sort A and return A[i]. Best Time cost will be O(nlgn). Divide: Using the Quick Sort Rand原创 2013-04-14 15:11:40 · 787 阅读 · 0 评论 -
The Program of Algorithms ------- Sorting in Linear Time---- Bucket Sort
Bucket Sort: Bucket sort assumes that the input is generated by a random process that distributes elements uniformly and independently over the interval [0,1). That is to say, the input number shou原创 2013-04-13 15:54:35 · 799 阅读 · 0 评论 -
The Program of Algorithms ------- Sorting in Linear Time---- Counting Sort
Input: A[1...n], each 0 Output: B[1...n] = sorting of A Auxiliary: C[1...k] Restricts: 1. each element little than a const "k" 2. the element should be integer 3. the range of the elements原创 2013-04-13 14:03:29 · 831 阅读 · 0 评论 -
The Program of Algorithms ------- Diveide and Conquer ---- Quicksort
Divide and Conquer: 1. Divide: Partition array into 2 subarrays around pivot, such that elements in lower subarray little than pivot, and upper subarray bigger than pivot. 2. Conquer: Recursive原创 2013-04-03 20:23:15 · 771 阅读 · 0 评论 -
The Program of Algorithms ------- Diveide and Conquer ---- Matrix Multiplication
Q: Input: A=[a_ij] B=[b_ij] i,d=1,2,3...n Output: C=[c_ij]=A*B Naive Algorithm: Θ(n^3) Realization --- CPP: long int** NaiveMatrixMulitiple(long int** lhs,long int** rhs,long int size原创 2013-04-03 20:14:04 · 845 阅读 · 0 评论 -
The Program of Algorithms ------- Diveide and Conquer ---- Powering a number
Q: given number x, and n>=0 compute x^n. Naive Algorithm: x*x*x*......*x=x^n Time:Θ(n) Divide and Conquer Algorithm: X^n=(X^2)^(n/2) if n is a原创 2013-04-03 19:43:27 · 937 阅读 · 0 评论 -
The Program of Algorithms ------- Diveide and Conquer ---- Merge Sort
Merge Sort: 1. Divide: Divide the input array into two subarray(n/2 and n/2). 2. Conquer: Recursively sort each subarray. 3. Combine: Linear-Time merge. Running Time: T(n)=2T(n/2)+Θ(n).原创 2013-04-03 19:34:34 · 793 阅读 · 0 评论 -
The Program of Algorithms ------- Diveide and Conquer ---- Fibonacci
Definition: Fn = 0 if n==0 Fn = 1 if n==1 Fn = F_n-1 + F_n-2 if n原创 2013-04-03 19:58:00 · 903 阅读 · 1 评论 -
The notes of Algorithms ---- Solving Recurrences
There are three solutions to solve the recurrences. Substitution method: 1. Guess the form of the solution 2. Verify by induction 3. Slove for consts Recursion-tr原创 2013-04-01 22:02:53 · 674 阅读 · 0 评论 -
The notes of Algorithms ---- Dynamic Programming
Two key ingredients: #1 Optimal Substructure: If an optimal solution to the problem exhibits optimal solution to subproblems. Some common pattern: 1. You show that a so原创 2013-04-17 22:47:11 · 835 阅读 · 0 评论