Embercode
✕
Binary TreesQuick quiz

Columns and zigzags

8 questions. Covers Zigzag and spiral level order in Python.

Questions 1 to 5 of 8

  1. 1. Build tree X with the node(value, left, right) helper, which is TreeNode(value, left, right) from this lesson, then run vertical_order from this lesson. ``python x = node(8, node(3, node(1, None, None), node(6, node(4, None, None), node(7, None, None))), node(10, None, node(14, node(13, None, None), None))) print(vertical_order(x)) `` What does the program print?
  2. 2. Using tree X from the previous question, what does zigzag_reverse print? Levels are counted from 1 at the root. ``python print(zigzag_reverse(x)) ``
  3. 3. Using tree X again, what does boundary print? ``python print(boundary(x)) ``
  4. 4. Why does zigzag_reverse reverse only the printed list of a level, and not the queue?
  5. 5. Why does the top view use setdefault instead of plain assignment (top[col] = value)?

5 question(s) left on this page.