🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← 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))
  1. A.24
  2. B.32
  3. C.64
  4. 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 →