MCS-211 · Block 1 Unit 3

Complexity Analysis of Simple Algorithms

8 sections

Block 1 · Unit 3Complexity Analysis of Simple Algorithms65 min · 8 sections

Unit 3Complexity Analysis of Simple Algorithms

Follows IGNOU MCS-211, Block 1 Unit 3

The previous unit gave you the language of growth rates; this unit puts it to work. You will learn rules for finding the running time of loops, conditionals and recursive calls, and then apply them to a set of classic small algorithms: summing cubes, evaluating a polynomial, multiplying matrices, computing powers quickly, searching and sorting. Each analysis follows the same pattern — choose the basic operation, count how often it runs, and express the count with O, Ω or Θ — which is the skill you will use in every later unit.

In this unit you will learn to

  • find the running time of simple statements, loops (for, while, nested, consecutive) and if–else;
  • count the exact steps of a simple algorithm and simplify the count to a growth class;
  • evaluate a polynomial by brute force and by Horner’s rule and compare their costs;
  • analyse the standard n×nn \times n matrix multiplication algorithm;
  • compute ana^n with left-to-right and right-to-left binary exponentiation in O(log⁡n)O(\log n) multiplications;
  • analyse the best, worst and average case of linear search;
  • analyse three versions of bubble sort;
  • analyse Euclid’s algorithm and simple recursive algorithms.

Sections in this unit

  1. 3.1Analysing Simple ConstructsRunning times of simple statements, for loops with steps, multiplying and dividing loops, nested and consecutive loops, while loops and if–else.7 min
  2. 3.2Counting Steps: The Summation AlgorithmExact step counting for the sum-of-cubes algorithm (6n + 4 units) and the general rules for turning a step count into Big-O.9 min
  3. 3.3Polynomial Evaluation and Horner's RuleBrute-force polynomial evaluation (n(n+1)/2 multiplications) versus Horner's rule (n multiplications), with corrected pseudocode and examples.9 min
  4. 3.4Matrix MultiplicationThe standard algorithm for multiplying two n×n matrices, a worked 3×3 example, a C program, and why it takes Θ(n³) time.8 min
  5. 3.5Exponent Evaluation: Binary ExponentiationComputing aⁿ with O(log n) multiplications using left-to-right and right-to-left binary exponentiation, with corrected pseudocode and a²⁸³ traces.6 min
  6. 3.6Linear Search: Best, Worst and Average CaseLinear search with a corrected C implementation, the best, worst and average number of comparisons, and why the worst case is the default.9 min
  7. 3.7Sorting: Bubble Sort and Its AnalysisInternal vs external sorting, bubble sort traced pass by pass, and the comparisons and swaps of three versions with corrected analysis.11 min
  8. 3.8Euclid's Algorithm and Recursive ConstructsProgramme-guide topics: why Euclid's GCD algorithm takes O(log n) rounds, and how to analyse recursive algorithms with recurrences.6 min
↑ ↓ move↵ openTab switch type