Compute the factorial of a number using recursion.
O(n) – one recursive call for each value of n
O(n) – recursion stack grows to depth n
Compute the nth Fibonacci number using recursion.
This approach is inefficient because the same Fibonacci values are recalculated multiple times.
O(2ⁿ) – exponential number of recursive calls
O(n) – recursion depth
Previously computed Fibonacci values are stored in memory to avoid repeated calculations.
O(n) – each Fibonacci number is computed once
O(n) – memo table and recursion stack
Move N disks from source peg to destination peg using an auxiliary peg.
Move disk 1 from A to C
Move disk 2 from A to B
Move disk 1 from C to B
Move disk 3 from A to C
Move disk 1 from B to A
Move disk 2 from B to C
Move disk 1 from A to C
Total moves = 7
O(2ⁿ)
O(n)
Search for an element in a sorted array using recursion.
At each step, the array is divided into two halves.
O(log n)
O(log n)
All required recursive algorithms are implemented and analyzed according to Unit 1 syllabus.