← Quiz: Solving Recurrences: all 15 questions
Quiz: Solving Recurrences · Question 8 of 15
Unrolling T(n) = T(n − 1) + n with T(1) = 1 gives:
Unrolling T(n) = T(n − 1) + n with T(1) = 1 gives:
- A.n log n
- B.2ⁿ − 1
- C.n²
- D.n(n + 1)/2
Answer & explanation
Correct answer: n(n + 1)/2
T(n) = 1 + 2 + … + n, which is n(n + 1)/2, or Θ(n²).
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 →