Unit summary

  • An algorithm is finite, definite, effective and has input and output; analysis counts basic operations apriori.
  • Time and space complexity depend on input size; worst case is the standard guarantee.
  • O, Ω and Θ give upper, lower and tight bounds ignoring constants.
  • Sequential search is Θ(n); bubble and selection sort are Θ(n²); insertion sort is Θ(n) to Θ(n²).
  • Classical matrix multiplication is Θ(n³) with three nested loops.
  • Recursive algorithms yield recurrences solved by expansion, trees or the Master theorem.

Glossary

Term Meaning
Algorithm Finite sequence of steps solving a problem.
Apriori analysis Counting steps before running the program.
Base case Smallest instance solved directly.
Basic operation The most frequently executed step.
Big-O Upper bound on growth.
In place Uses only O(1) extra memory.
Master theorem Solves T(n) = aT(n/b) + f(n).
Omega Lower bound on growth.
Recurrence Equation for T(n) in terms of smaller inputs.
Recursion tree Tree of calls used to sum the work.
Space complexity Extra memory as a function of n.
Stable sort Keeps equal keys in input order.
Theta Tight bound on growth.
Time complexity Basic operations as a function of n.

Question bank

Short Answer Questions (2 marks each)

  1. Define an algorithm.
  2. What is a basic operation?
  3. Distinguish best, worst and average case.
  4. Define Big-O notation.
  5. What is Θ notation?
  6. How many comparisons does selection sort make?
  7. State the best case of insertion sort.
  8. What is a recurrence relation?
  9. Write the recurrence for merge sort.
  10. State Case 2 of the Master theorem.

Medium Answer Questions (5 marks each)

  1. Explain the properties of an algorithm.
  2. Explain O, Ω and Θ notations with examples.
  3. Analyse bubble sort for best and worst cases.
  4. Analyse insertion sort with an example.
  5. Analyse the classical matrix multiplication algorithm.
  6. Solve T(n) = 2T(n/2) + n by the recursion tree method.

Long Answer Questions (15 marks each)

  1. Explain time and space complexity and the three asymptotic notations with proofs of bounds.
  2. Analyse sequential search, bubble sort, selection sort and insertion sort for all cases.
  3. Explain recursion, write recurrences and solve them by substitution.
  4. State the Master theorem and solve five recurrences with it.

Sources

  • Official BCA syllabus Design and Analysis of Algorithms, course code 26BCA404DS03, Unit I