Beruflich Dokumente
Kultur Dokumente
http://www.youtube.com/watch?v=EL9T1ngiCqA http://video.google.com/videoplay?docid=6724701313234177393
Asymptotic Notation
Formal way notation to speak and classify them Asymptotic analysis refers to classifying the behaviour of functions
Two Features:
there are consts c > 0 and n0 > 0 such that 0 <= f(n) <= cg(n) for all n > n0 Example: 2n^2 = O(n^3) Set definition O(g(n)) = { f(n) : there are consts c > 0, n0 > 0 such that 0 <= f(n) <= g(n) for all n > n0 } Example:
Or
Macro Definition A set in a formula represents an anonymous function in that set. Example:
such that
, there is an
Omega Notation M(g(n)) = { f(n) : there exist consts c > 0, n0 > 0 such that 0 <= c g(n) <= f(n) for all n > n0 } Example:
Theta notation thetha(g(n)) = { f(n) : there exist consts c1 > 0, c2 > 0, n0 > 0 such that c1g(n) <= f(n) <= c2g(n) for all n >= n0 Example:
o & m notations (< / >) inequality must hold for all consts c > 0 Example:
Solving recurrences Substitution method 1. Guess the form of the solution 2. Verify by induction 3. Solve for consts Example: T(n) = 4T(n/2) + n T(1) = O(1) Guess: T(n) = O(n^3) Assume: T(k) <= c k^3 for k < n Thus, T(n) = 4T(n/2) + n T(n) <= 4 c(n/2)^3 + n <= 1/2cn3 + n = cn^3 residual <= cn^3 , if 1/2cn^3 n >= 0 Try: T(n) = O(n^2) Assume: T(k) <= ck^2 for k < n T(n) = 4T(n/2) + n <= 4c(n/2)^2 + n = cn^2 + n = cn^2 (n ) Want: n >= 0 Assume: T(k) <= c1k^2 c2k T(n) = 4T(n/2) + n
<= 4(c1(n/2)^2 c2(n/2)) + n = c1n^2 2c2n + n = c1n^2 c2n (n + c2n) Want: n + c2n >= 0 Recursion-Tree Method Example: T(n) = T(n/4) + T(n/2) + n^2 Expand:
5^kn^2
= (1 + 5/16 + 25/256 + )n^2 RECALL: 1 + + + 1/8 + 1/64+ =1+1=2 Thus, <= 2n^2 = O(n^2) Master Method applies to recurrences of the form T(n) = aT(n/b) + f(n) Where: a>= 1, b > 1,
Compare:
modularity, correctness, maintainability, security, functionality, robustness, user-friendliness, programmers time, simplicity, extensibility, reliability, and scalability.
He also asks Why study algorithms and performance at all?. He and students answer:
Sometimes performance is correlated with user-friendliness. Performance draws line between feasible and unfeasible. Algorithms give language for talking about program behavior. Performance can be used to pay for other things, such as security, features and userfriendliness.
The lecture continues with the definition of the Sorting Problem - given a sequence (a1, a2, , an) of numbers, permute them in such a way that a1 <= a2 <= ... <= an. There are various algorithms to solve this problem. Two algorithms are presented to solve this problems - one of them is Insertion Sort and the other is Merge Sort. Running time of these algorithms is analyzed by introducing Asymptotic Analysis and Recursion Trees. Here is the whole lecture: Direct URL: http://video.google.com/videoplay?docid=-2333306016564732003 Topics covered in lecture 1:
[17:15] Main topic of the course - Analysis of algorithms. [19:00] Whats more important than performance? [22:03] Why study algorithms and performance? [27:45] The sorting problem. [29:30] Insertion sort algorithm [34:30] Example of Insertion sort. [36:25] Running time of algorithms. [39:39] Definition of worst-case, average-case and best-case types of analysis. [46:50] How to analyze the Insertion sorts worst-case running time?
[49:28] BIG IDEA - Asymptotic analysis. [50:49] Asymptotic notation - theta notation. [57:14] Insertion sort analysis. [01:02:42] Is Insertion sort fast? [01:03:40] Merge sort algorithm. [01:05:25] Example of Merge subroutine of Merge sort. [01:08:15] Analysis of Merge sorts running time. [01:10:55] Recurrence equation for Merge sort. [01:13:15] Recursion tree solution of the Merge sorts recurrence equation.
Lecture 1 notes:
Lecture 1, page 1 of 2.
Lecture 1, page 2 of 2.
Substitution method,
Here is the whole lecture: Direct URL: http://video.google.com/videoplay?docid=6724701313234177393 Topics covered in lecture 2:
[01:25] Big-o (upper bounds) notation. [03:58] Set definition of big-o notation. [05:25] The meaning of O(h(n)) in notation f(n) = g(n) + O(h(n)). [10:20] Big-omega (lower bounds) notation. [11:40] Analogies of O, and to comparison operations of real numbers. [12:28] Theta (tight bounds) notation. [13:40] Small-o and small-omega notation. [17:03] Solving recurrences: substitution method. [37:56] Recursion-tree method. [49:00] The Master method. [01:02:00] Proof sketch of the Master method.
Lecture 2 notes:
Lecture 2, page 1 of 2.
Lecture 2, page 2 of 2.
Have fun absorbing all this information! Until next post! Ps. It turned out that the lectures were not available anywhere but from MITs OCW website. I found that they were released under CC license, which allowed me to upload them to Google Video, so I can embed them in the posts! Pps. the lectures are taught from the CLRS book (also called Introduction to Algorithms):