Solving T(n) = T(n/2) + 1
Coding
Recurrences
Easy
Hint 1
Each recursive call halves the problem size while doing constant extra work.
Hint 2
Count how many times can be halved before reaching a constant size.
Show worked solution
1. Count the recursion depth
The problem size halves at each level, so after levels the size is ; recursion stops once this reaches a constant.
2. Sum the constant work per level
Each of the levels does work, giving total time .
Answer: O(log n)
Related roles: Browse quant jobs