Unit 1Analysis of Algorithms
Follows IGNOU MCS-208, Unit 1
Every data structure in this course is judged by one question: how much time and memory do its operations need as the data grows? This unit gives you the tools to answer that question. You will learn to measure an algorithm not in seconds, which change from machine to machine, but by its rate of growth, written with the notations O, Ω and Θ. These tools come back in every later unit, whenever two ways of storing or processing data are compared.
In this unit you will learn to
- explain what an algorithm is and list its five properties;
- describe what time and space complexity mean, and why we measure growth instead of seconds;
- use Big-O, Omega (Ω) and Theta (Θ) notation, and prove simple bounds by finding the constants and ;
- simplify growth functions with the rules of Big-O;
- count the steps of loops, nested loops and whole functions;
- tell best, worst and average case apart, using insertion sort as the example;
- find the space complexity of iterative and recursive programs;
- place common algorithms on the complexity ladder, from O(1) to O(n!).
Sections in this unit
- 1.1Algorithms and ComplexityWhat an algorithm is, its five properties, what complexity measures, the classes P and NP, and the space–time trade-off.13 min
- 1.2Asymptotic Notation: Big-O, Omega and ThetaFormal definitions of Big-O, Omega and Theta, how to prove a bound by finding c and n0, and how to show a bound is false.13 min
- 1.3Simplifying Growth Functions: Rules of Big-ORules for dropping constants and lower-order terms, comparing logs, polynomials, exponentials and factorials, with Check Your Progress 1.15 min
- 1.4The Process of Analysis and the RAM ModelPerformance vs complexity, the RAM model of computation, and rules for timing sequences, if-else, loops, nested loops and doubling loops.11 min
- 1.5Exact Step Counting: the psum FunctionCount every step of a simple C function exactly, then prove its count is O(n), Omega(n) and Theta(n) by choosing constants.7 min
- 1.6Best, Worst and Average Case: Insertion SortExact analysis of insertion sort, showing why its best case is Theta(n) and its worst and average cases are Theta(n squared).12 min
- 1.7Calculating Space ComplexitySpace complexity of iterative and recursive programs, why recursion depth sets memory use, with Fibonacci-style recursion and GCD.12 min
- 1.8Calculating Time Complexity: the Complexity LadderTime complexity of constant code, binary search and the travelling salesman problem, and the ladder of growth rates from O(1) to O(n!).10 min