Algorithm Study Notes
2012-05-16 16:35
183 查看
0.Master Method 时时勤拂拭
Master Theorem
Let a ³ 1 and b > 1 be constants, let f(n) be a function, and let T(n)
be defined as the nonnegative integers by the recurrence
T(n) = aT(n/b) + f(n),
where we interpret n/b to mean either ën/bû or én/bù.
Then T(n) can be bounded asymptotically as follows
If f(n) = O(nlogb a - e) for some constant e > 0, then T(n) = Q(nlogb a).
If f(n) = Q(nlogb a - e), then T(n) = Q(nlogb a lgn).
If f(n) = W(nlogb a + e) for some constant e > 0, and
if af(n/b) £ cf(n) for some constant c < 1 and all sufficiently large n,then T(n) = Q(f(n)).
Chapter 5. Random Algorithm
Expected Cost for hire = O(c_h*ln(n))
Master Theorem
Let a ³ 1 and b > 1 be constants, let f(n) be a function, and let T(n)
be defined as the nonnegative integers by the recurrence
T(n) = aT(n/b) + f(n),
where we interpret n/b to mean either ën/bû or én/bù.
Then T(n) can be bounded asymptotically as follows
If f(n) = O(nlogb a - e) for some constant e > 0, then T(n) = Q(nlogb a).
If f(n) = Q(nlogb a - e), then T(n) = Q(nlogb a lgn).
If f(n) = W(nlogb a + e) for some constant e > 0, and
if af(n/b) £ cf(n) for some constant c < 1 and all sufficiently large n,then T(n) = Q(f(n)).
Chapter 5. Random Algorithm
HIRE_ASSISTANT(n) { 1 best = 0; // candidate 0 is a least-qualified dummy candidate 2 for i = 1 to n { 3 interview candidate i; 4 if candidate i is better than candidate best { 5 best = i; 6 hire candidate i; 7 } 8 } } RANDOMIZED_HIRE_ASSISTANT(n) { 1 randomly permute the list of candidates 2 HIRE_ASSISTANT(n) } RANDOMIZE_IN_PLACE(A) { 1 n = A.length; 2 for i = 1 to n 3 swap(A[i], A[RANDOM(i, n)]); }
Expected Cost for hire = O(c_h*ln(n))
相关文章推荐
- Study notes for Expectation Maximum Algorithm
- Study notes for Expectation Maximum Algorithm
- Study notes for Principal Component Analysis
- D3 JS study notes
- Paper Notes: Near linear time algorithm to detect community structures in large-scale networks
- [study]10.1 BJ qbxt notes
- ZedBoard Study Notes -- Running the Qt Program
- websocket study notes
- study notes for EJB 3 in action (I)
- studyjams notes PS1 设计一个静态的app
- VBA Study Notes
- Webkit JNI study notes
- parrallel python study notes
- XUL Tutorial Study Notes - Introduction
- Git study notes
- Study notes for Anomaly Detection
- Asp.Net Design Pattern Studynotes -- Part1
- linux study notes
- JQuery Study Notes— A small demo for Smooth Animated Menu
- study notes for EJB 3 in action (II)