Skip to content
StackDecode
TreesExplained

Boundary Traversal

Left edge, then leaves, then right edge going up.

Time

O(n)

Extra space

O(h)

Use it for

Printing the outline of a tree.

An animated walkthrough for this algorithm isn’t built yet. The summary above explains the idea; see the related animated algorithms below to practise the same technique.