1 / 14

CSE 3358 Note Set 3

CSE 3358 Note Set 3. Data Structures and Algorithms. Overview:. More Big-oh Big Omega and Big Theta Calculating T(n) for a particular algorithm. Typical Growth Rates. Revisiting Big Ω.

sian
Download Presentation

CSE 3358 Note Set 3

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CSE 3358 Note Set 3 Data Structures and Algorithms

  2. Overview: • More Big-oh • Big Omega and Big Theta • Calculating T(n) for a particular algorithm

  3. Typical Growth Rates

  4. Revisiting Big Ω • T(N) = Ω (g(n)) if there are positive constants c and n0such that T(N) >= c*g(n) when N >= n0.

  5. Revisiting Big  • T(N) = (h(n)) iffT(N) = O(h(n)) and T(N) = Ω (h(n)) .

  6. Properties of Big O If f(n)=O(g(n)) and g(n)=O(h(n)), then f(n)=O(h(n)). (Transitivity) If f(n)= O(h(n)) and g(n)= O(h(n)), then f(n) + g(n) = O(h(n)). (Addition) The function ank= O(nk). The function nk= O(nk+j) for any positive j.

  7. Other Rules • If f(n) is a polynomial of degree k, then f(n) =O(nk) • logk n = O(n) for any constant k.

  8. Random Access Machine • “Generic” Computer • Helps us analyze the running time of an algorithm • Count the individual number of steps needed • Simple operations take one time unit • +, -, *, /, comparison, function call, etc • Complex structures such as methods and loops take longer (obviously ) • Not worried about different types of memory acces (cache, ram, disk) – all 1 time unit

  9. Example 1 inty = 10; y = y + x; return y;

  10. Example 2 if (x < 10) return 25; else return 30;

  11. Example 3 int sum = 0; for (inti = 0; i < num; i++) sum = sum + arr[i]; return sum;

  12. Example 4 for (inti = 0; i < n ; i++) for (int j = 0; j < n; j++) k++;

  13. Observations • Loops usually increase complexity • Nested loops usually increase complexity more • Shortcut w/ RAM Model • Typically, only comparisons need to be counted • As types of ops are abstracted away, detail of T(n) reduced – but usually sufficient to come up with O() notation

  14. ?

More Related