Level-Order Traversal and Right Side View

easy
Unit 5 · Trees0/3 to milestone

Using a queue (collections.deque), implement:

  • levels(root): a list of lists, one per depth, values left to right
  • zigzag(root): like levels but alternate direction each level (first level left-to-right)
  • right_view(root): the last value of each level (what you'd see from the right)
#trees#bfs2 visible + 1 hidden tests
solution.py · Python 3.13
Loading editor…
Run your code to see results. ⌘↵ to run · ⌘⇧↵ to submit
Level-Order Traversal and Right Side View · TechGradify