DAA Study Hub

Which technique?

Recognise which method a question wants.

Exam questions rarely name the method. Use this page to go from what the question looks like to what to do. It grows as the course continues (greedy, DP and graphs get added when we reach them).

"Analyse this…" questions

If the question shows…Do thisTopic
loops with fixed boundsmultiply the loop sizes (inside-out)5
an inner loop bound that depends on the outer variablewrite the sum, use a closed form0, 5
a counter that doubles/halveslog⁡n\log n iterations5
a function that calls itselfwrite the recurrence T(n)=…T(n) = \dots8
T(n)=aT(n/b)+f(n)T(n) = aT(n/b) + f(n)recursion tree → equal / shrinking / growing levels8
T(n)=T(n−1)+…T(n) = T(n-1) + \dotsexpansion (unroll), then a sum8
"prove T(n)=O(… )T(n) = O(\dots)" for a recurrenceguess from the tree, then induction (substitution)8
"best / worst case"find the input that makes the inner loop shortest / longest4

"Prove…" questions

If the question says…UseTopic
"show f(n)=O/Ω/Θ(g(n))f(n) = O/\Omega/\Theta(g(n))"find explicit cc (c1,c2c_1, c_2) and n0n_06
"show f(n)≠O(g(n))f(n) \ne O(g(n))"contradiction: get n≤n \le constant6
"prove this loop algorithm is correct"loop invariant: Init / Maintenance / Termination3
"prove this recursive algorithm is correct"induction on nn3
"prove for all n≥1n \ge 1" (a sum or formula)induction2
"there is no…" / "impossible"contradiction2
"if P then Q" where "not Q" is concretecontraposition2

"Design an algorithm…" questions (strategy picker)

Problem smellTry firstNotes
small input, or you just need something correctBrute forcetry every possibility; often n2n^2, n3n^3 or 2n2^n
splits into independent halves that combine cheaplyDivide & conquere.g. merge sort, binary search; write the recurrence
"build the answer one element at a time, keeping it valid"Incrementale.g. insertion sort; prove with a loop invariant
a locally best choice seems to never hurtGreedycoming later in the course
subproblems overlap / repeatDynamic programmingcoming later in the course
networks, routes, connectionsGraph algorithmscoming later in the course

Assignment write-ups (per the course rules, Intro Slide 19) need: a plain-English description, a worked example, a correctness argument and a running-time analysis. Each topic page models all four.

On this page