Pages - Menu

Wednesday, February 3, 2016

Mnemonic device for Tree Traversal

Tree traversal might be confusing sometimes. The slides below will show you how to do it easily !

# The Mnemonic devices are for : Pre-Order, In-Order and Post-Order traversal.

Rules:

1. Think Root as the main thing.
2. Left always comes before right.

Pre-Order: It means, the root is coming before. And we know left always comes before right. So:
Root -- Left -- Right

In-Order:  It means the root is inside, or in-between. And we know left always comes before right. So:
Left -- Root -- Right

Post-Order: It means the root will come at the end. And we know left always comes before right.
Left -- Right -- Root



No comments:

Post a Comment