0
votes

I am not understanding how to draw a Binary Tree give traversals. Could someone explain to me inorder, preorder, and postorder traversals in a more efficient way?

For example:

Reconstruct the exact BINARY tree given the following traversals:

Inorder:

9, 2, 10, 6, 5, 8, 3, 1, 4, 7 

Post order:

9, 10, 2, 6, 8, 3, 7, 4, 1, 5
1

1 Answers

0
votes

One of the best example I've found explaining this is here (click 'Traversals' on the left menu, then 'Start Lesson' for the demo) as it has a completely pictorial explanation of what is happening

Short version

  • Preorder is DLR: Data, Left, Right
  • Inorder is LDR: Left, Data, Right
  • Postorder is LRD: Left, Right, Data