Coursify

Design and Analysis of Algorithms (DAA)

PYQ Analysis & Exam Preparation — Module 1

45 mins

A strategic analysis of 20 exam questions spanning 2022–2024. Module 1 heavily tests recurrences (Master's theorem & substitution method) and asymptotic notation theory. Know exactly what to practice.

Learning Goals

  • Identify the three guaranteed question types: Master's theorem applications, substitution method traces, and asymptotic notation explanations.
  • Practice with actual MCQ questions from 2022–2024 papers.
  • Understand the answer structure for the highest-mark theoretical questions: O/Ω/Θ definitions and best/worst/average case analysis.

The Exam Blueprint: Module 1 PYQ Deep Analysis (2022–2024)

An analysis of 20 exam questions spanning 2022 to 2024 reveals that Module 1 is foundational and predictable. Master's Theorem and the Substitution Method are guaranteed to appear every single year for 5–7 marks each. The theoretical aspect strictly focuses on Asymptotic Notations and Time/Space Complexity definitions.

Complete PYQ Table (20 Questions)

YearQ#MarksTopicType
2023Q1a2Worst-case notation = Big-OMCQ
2024Q1a2Space complexity definitionMCQ
2024Q1b2Asymptotic upper bound of 5n²+3n+7MCQ
2022Q1b2max{f(n), g(n)} for two independent complexitiesMCQ
2024Q1c2T(n)=T(n/2)+1 → O(log n)MCQ
2023Q1d2Stable O(n²) sort = Insertion SortMCQ
2023Q1e2T(n)=2T(n/4)+n²logn → Θ(n²logn)MCQ
2022Q1f2Asymptotically smallest functionMCQ
2023Q1f2Space complexity = memory usedMCQ
2022Q1h2Merge sort avg comparisons for 2-element lists = 8/3MCQ
2023Q2a7Explain asymptotic notation (Big-O, Ω, Θ)Theory
2024Q2a7Best/worst/average case + linear search examplesTheory
2022Q2a7Substitution method: f(n)=3f(n/2)+6, f(1)=1Numerical
2023Q2b7Substitution method: T(n)=2T(n/2)+nNumerical
2024Q2b7Substitution method: T(n)=T(n-1)+n, T(1)=1Numerical
2023Q3a5Master Theorem: T(n)=4T(n/2)+n³ and T(n)=T(n/2)+2ⁿNumerical
2024Q3a7Master Theorem: 3 cases + apply to 3 recurrencesNumerical
2023Q4a7Linear search trace + time/space complexity analysisTheory+Num
2022Q8b7Master Theorem + T(n)=2T(n^(1/2))+log nNumerical
2022Q914Short notes: Asymptotic NotationsTheory

Total marks tracked: 108 marks across 3 years.


Topic Heat Map

Topic202220232024Total Marks
Asymptotic Notation (O/Ω/Θ theory)9M ✅9M ✅7M ✅25M
Substitution Method7M ✅7M ✅7M ✅21M
Master's Theorem7M ✅5M ✅7M ✅19M
MCQ — Complexity Analysis4M ✅6M ✅6M ✅16M

The 3 Guaranteed Question Types

1. 🔴 Substitution Method Recurrence (7M) — appeared in ALL 3 years Always a different form. You must show the expansion steps clearly, generalize to the kk-th step, and substitute the base case. Examples: 3f(n/2)+63f(n/2)+6, 2T(n/2)+n2T(n/2)+n, T(n1)+nT(n-1)+n.

2. 🔴 Master's Theorem Application (5–7M) — appeared in ALL 3 years You must state the values of aa, bb, and f(n)f(n), calculate nlogban^{\log_b a}, and explicitly state which Case applies. Watch out for equations where the theorem fails (like T(n)=2T(n/2)+n/lognT(n) = 2T(n/2) + n/\log n).

3. 🟠 Asymptotic Notation Theory (7M) — appeared in ALL 3 years Either "explain O/Ω/Θ" or "differentiate best/worst/average cases." Always include graphs and a standard example (like Linear Search) in your answers.

Solved Numericals: The Exam-Critical Calculations


Numerical 1: Substitution Method

"T(n) = T(n−1) + n, with T(1) = 1. Solve using substitution method."

Step 1: Expand the recurrence T(n)=T(n1)+nT(n) = T(n-1) + n T(n1)=T(n2)+(n1)T(n-1) = T(n-2) + (n-1) T(n2)=T(n3)+(n2)T(n-2) = T(n-3) + (n-2)

Step 2: Substitute back T(n)=[T(n2)+(n1)]+nT(n) = [T(n-2) + (n-1)] + n T(n)=[T(n3)+(n2)]+(n1)+nT(n) = [T(n-3) + (n-2)] + (n-1) + n

Step 3: Generalize for k steps T(n)=T(nk)+(n(k1))++(n1)+nT(n) = T(n-k) + (n-(k-1)) + \dots + (n-1) + n

Step 4: Reach the base case We reach the base case when nk=1    k=n1n-k = 1 \implies k = n-1. T(n)=T(1)+2+3++(n1)+nT(n) = T(1) + 2 + 3 + \dots + (n-1) + n T(n)=1+2+3++nT(n) = 1 + 2 + 3 + \dots + n

Step 5: Solve This is the sum of the first nn natural numbers. T(n)=n(n+1)2=n22+n2T(n) = \frac{n(n+1)}{2} = \frac{n^2}{2} + \frac{n}{2} Complexity: O(n2)O(n^2)


Numerical 2: Master's Theorem Cases

"Use Master's Theorem to solve: (i) T(n) = 2T(n/2) + n, (ii) T(n) = 3T(n/2) + n², (iii) T(n) = 2T(n/2) + n/log n. Explain which case applies."

(i) T(n)=2T(n/2)+nT(n) = 2T(n/2) + n

  • a=2,b=2,f(n)=na=2, b=2, f(n)=n
  • nlogba=nlog22=n1=nn^{\log_b a} = n^{\log_2 2} = n^1 = n
  • Since f(n)=Θ(nlogba)f(n) = \Theta(n^{\log_b a}), Case 2 applies.
  • Solution: T(n)=Θ(nlogn)T(n) = \Theta(n \log n)

(ii) T(n)=3T(n/2)+n2T(n) = 3T(n/2) + n^2

  • a=3,b=2,f(n)=n2a=3, b=2, f(n)=n^2
  • nlogba=nlog23n1.58n^{\log_b a} = n^{\log_2 3} \approx n^{1.58}
  • Since f(n)=Ω(nlogba+ϵ)f(n) = \Omega(n^{\log_b a + \epsilon}) for ϵ0.4\epsilon \approx 0.4, we check the regularity condition: 3(n/2)2cn2    34n2cn23(n/2)^2 \le c n^2 \implies \frac{3}{4} n^2 \le c n^2 (holds for c3/4c \ge 3/4).
  • Case 3 applies.
  • Solution: T(n)=Θ(n2)T(n) = \Theta(n^2)

(iii) T(n)=2T(n/2)+n/lognT(n) = 2T(n/2) + n/\log n

  • a=2,b=2,f(n)=n/logna=2, b=2, f(n) = n/\log n
  • nlogba=nlog22=nn^{\log_b a} = n^{\log_2 2} = n
  • We compare f(n)=n/lognf(n) = n/\log n with nn. Here, f(n)f(n) is asymptotically smaller than nn, but NOT polynomially smaller (the ratio is logn\log n, not nϵn^\epsilon).
  • Master's Theorem DOES NOT APPLY (it falls into the gap between Case 1 and Case 2).

Numerical 3: The Variable Substitution Trap

"Find time complexity: T(n) = 2T(n^(1/2)) + log n"

This cannot be solved directly by Master's Theorem. We must transform it. Let n=2m    m=log2nn = 2^m \implies m = \log_2 n. Substitute nn: T(2m)=2T(2m/2)+mT(2^m) = 2T(2^{m/2}) + m

Now, rename the function to make it look standard: Let S(m)=T(2m)S(m) = T(2^m). S(m)=2S(m/2)+mS(m) = 2S(m/2) + m

Now apply Master's Theorem to S(m)S(m):

  • a=2,b=2,f(m)=ma=2, b=2, f(m)=m
  • mlog22=mm^{\log_2 2} = m
  • f(m)=Θ(m)f(m) = \Theta(m), so Case 2 applies.
  • Solution for S(m)S(m): S(m)=Θ(mlogm)S(m) = \Theta(m \log m)

Substitute back m=lognm = \log n: T(n)=Θ(lognlog(logn))T(n) = \Theta(\log n \cdot \log(\log n))

Knowledge Check

Question 1 of 6
Q1Single choice

Which of the following notations is used to represent the worst-case time complexity of an algorithm?

High-Yield Subjective Bank: Structure Your Answers


####Explain Asymptotic Notations (7 Marks)**

Answer structure:

  1. Definition (1M): Asymptotic notations are mathematical tools used to represent the time and space complexity of algorithms as input size nn \to \infty.
  2. Big-O (O) Notation - Upper Bound (2M):
    • Represents the worst-case scenario.
    • f(n)=O(g(n))f(n) = O(g(n)) if there exist constants c>0c > 0 and n00n_0 \ge 0 such that 0f(n)cg(n)0 \le f(n) \le c \cdot g(n) for all nn0n \ge n_0.
    • Draw a graph showing cg(n)c \cdot g(n) staying above f(n)f(n) after n0n_0.
  3. Big-Omega (Ω) Notation - Lower Bound (2M):
    • Represents the best-case scenario.
    • f(n)=Ω(g(n))f(n) = \Omega(g(n)) if there exist constants c>0c > 0 and n00n_0 \ge 0 such that 0cg(n)f(n)0 \le c \cdot g(n) \le f(n) for all nn0n \ge n_0.
    • Draw a graph showing cg(n)c \cdot g(n) staying below f(n)f(n) after n0n_0.
  4. Big-Theta (Θ) Notation - Tight Bound (2M):
    • Represents the exact bound (average case).
    • f(n)=Θ(g(n))f(n) = \Theta(g(n)) if there exist constants c1,c2>0c_1, c_2 > 0 and n00n_0 \ge 0 such that 0c1g(n)f(n)c2g(n)0 \le c_1 \cdot g(n) \le f(n) \le c_2 \cdot g(n) for all nn0n \ge n_0.
    • Draw a graph showing f(n)f(n) sandwiched between c1g(n)c_1g(n) and c2g(n)c_2g(n).

Differentiate Best, Worst, Average Case + Why Worst is Preferred (7 Marks)**

Answer structure:

  1. Best Case (1.5M): Minimum time required for program execution. For Linear Search on array AA, the target is at A[0]A[0]. Complexity: Ω(1)\Omega(1). Not very useful for practical guarantees.
  2. Worst Case (1.5M): Maximum time required. Target is at the very end or not in the array at all. The algorithm must check all nn elements. Complexity: O(n)O(n).
  3. Average Case (1.5M): Expected time over all possible inputs. For Linear Search, target is somewhere in the middle (expected checks = n/2n/2). Complexity: Θ(n)\Theta(n).
  4. Why Worst-Case is Preferred (2.5M):
    • It provides an absolute guarantee — the algorithm will never take longer than this.
    • Crucial for real-time systems (e.g., medical devices, avionics) where missing a deadline causes failure.
    • Average-case is often mathematically difficult to compute and depends on assumptions about input probability distributions that might not hold true in reality.
PYQ Analysis & Exam Preparation — Module 1 | Design and Analysis of Algorithms (DAA) | Coursify