← Quiz: Solving Recurrences: all 15 questions
Quiz: Solving Recurrences · Question 7 of 15
What does this print? (code)
What does this print?
def T(n):
return 1 if n == 1 else 2 * T(n // 2) + n
print(T(8))
- A.24
- B.32
- C.64
- D.17
Answer & explanation
Correct answer: 32
Unrolled, T(n) = n·log₂ n + n = 8·3 + 8 = 32.
Can you get the rest right without peeking?
Take the timed Quiz: Solving Recurrences quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →