Analysis Order notation September 07 2018 Cinda Heeren
Analysis Order notation September 07, 2018 Cinda Heeren / Geoffrey Tien 1
Reminders • Labs start next week – TAs still available this week for helping to set up your programming environment • Homework 1 expected to release tonight – check course webpage • Limited machine availability in labs – bring your own laptop if possible September 07, 2018 Cinda Heeren / Geoffrey Tien 2
Review: O-notation • We want comparison to be valid for all sufficiently large inputs, but we are willing to ignore behaviour on small examples. Scale up the simple function if necessary Time Find input size where T(n) is bounded by scaled function Input size September 07, 2018 Cinda Heeren / Geoffrey Tien 3
Other flavours of order notation • September 07, 2018 Cinda Heeren / Geoffrey Tien 4
Ω-notation, visually • Time Input size September 07, 2018 Cinda Heeren / Geoffrey Tien 5
Θ-notation, visually • Time Input size September 07, 2018 Cinda Heeren / Geoffrey Tien 6
Asymptotic analysis hacks Running time approximation • September 07, 2018 Cinda Heeren / Geoffrey Tien 7
Examples • September 07, 2018 Cinda Heeren / Geoffrey Tien 8
Let's race! • September 07, 2018 Cinda Heeren / Geoffrey Tien 9
Common growth rate functions • September 07, 2018 Cinda Heeren / Geoffrey Tien 10
Dominance • September 07, 2018 Cinda Heeren / Geoffrey Tien 11
Analyzing code Types of analysis • Bound flavour – Upper bound (O) – Lower bound (Ω), useful for problems – Asymptotically tight (Θ) • Analysis case – – Worst case (adversary) Average case Best case / "lucky" case "common" case • Analysis quality – Loose bound (any true analysis) – Tight bound (no better "meaningful" bound that is asymptotically different) September 07, 2018 Cinda Heeren / Geoffrey Tien 12
Input varies • The number of operations usually varies based on the size of the input – Though not always – consider array lookup • In addition algorithm performance may vary based on the organization of the input – For example consider searching a large array – If the target is the first item in the array the search will be very fast September 07, 2018 Cinda Heeren / Geoffrey Tien 13
Readings for this lesson • Epp – Chapters 11. 2 – 11. 3 • Carrano & Henry – Chapter 10 • Next class: – Code analysis, searching • For those unfamiliar with C++, we recommend reading Carrano & Henry's C++ Interlude chapters – For now, Chapter C 1. 1 • The Zych notes linked on the course webpage are highly recommended September 07, 2018 Cinda Heeren / Geoffrey Tien 14
- Slides: 14