Embercode
✕
Time and Space ComplexityQuick quiz

Recurrence trees

7 questions. Covers Recurrence trees.

Questions 1 to 5 of 7

  1. 1. For T(n) = T(n/2) + n, the number of levels is log base ____ of n.

    Type your answer.

  2. 2. For T(n) = 2 T(n - 1) + 1, the total work is 2 to the power n minus 1, which is ____ growth.

    Type your answer.

  3. 3. For T(n) = 2 T(n - 1) + 1, which statements about the recursion tree are correct?

    Pick every answer that is true.

  4. 4. For T(n) = T(n/2) + n with n = 1024, which statements are correct?

    Pick every answer that is true.

  5. 5. What does this code print? ``python def level_totals(n, children, cost): totals = [] level = [n] while level: totals.append(sum(cost(s) for s in level)) nxt = [] for s in level: nxt.extend(children(s)) level = nxt return totals kids = lambda s: [s - 2, s - 2] if s > 1 else [] cost = lambda s: s if s > 1 else 0 totals = level_totals(7, kids, cost) print(totals, sum(totals)) ``

5 question(s) left on this page.

Typed answers ignore extra spaces and, for most questions, capital letters.