
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 · 819 阅读 · 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 · 1056 阅读 · 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 · 842 阅读 · 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 · 844 阅读 · 0 评论 -
The Program of Algorithms ------- Sorting in Linear Time---- Counting Sort
Input: A[1...n], each 0Output: B[1...n] = sorting of AAuxiliary: C[1...k]Restricts: 1. each element little than a const "k"2. the element should be integer3. the range of the elements原创 2013-04-13 14:03:29 · 890 阅读 · 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 · 810 阅读 · 0 评论 -
The Program of Algorithms ------- Diveide and Conquer ---- Matrix Multiplication
Q:Input: A=[a_ij] B=[b_ij] i,d=1,2,3...nOutput: 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 · 896 阅读 · 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 · 983 阅读 · 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 · 855 阅读 · 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 · 950 阅读 · 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 constsRecursion-tr原创 2013-04-01 22:02:53 · 712 阅读 · 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 · 878 阅读 · 0 评论