Skip to content
DSA Visualizerpreview

Level-order traversal

Level by level with a queue: breadth-first search on a tree.

O(n) time · O(width) for the queue space

Values50, 30, 70, 20, 40, 60, 80

The tree built from 50, 30, 70, 20, 40, 60, 80. Visit every node level-order.

Tree with 7 nodes; in order: 20, 30, 40, 50, 60, 70, 80. Visited so far: none.
  • compare
  • swap or write
  • settled

1 / 15

Speed

Space play · ← → step · Home End jump · drag the strip to scrub