38/38
Part 7 of 7 · Follow-upsCheck yourself
Check yourself
6 questions
  1. 1.Why does a walk down a tree from its top not need a seen-set, when a walk over a grid does?

  2. 2.A recursive size written as 1 + sum(size(child) for child in children[node]) handles a chain of 499 nodes and raises RecursionError at 500. Written with a plain for loop, it reaches 999. Why the difference?

  3. 3.Which of these can only be computed after a node's children are done?

  4. 4.With your own stack, you record the order regions come off it, then compute subtree sizes walking that order. Which direction works?

  5. 5.Word search marks each cell it steps on. What breaks if it never unmarks a cell when it backs out?

  6. 6.You keep a total per node and walk up the parents on every change. On a chain of 100,000 nodes, what does a change at the bottom and a read of the top cost?

Now the problem this lesson builds to: 34 Regions inside regionsPractice it