Sunday, March 15, 2009

Tree Traversal Ordering - Whats the order again?

I have always had trouble remembering what exactly are the orders of inorder, preorder and postorder traversals. Well today I think iv had the defining insight :). the "IN","PRE" and "POST" is based on where the root node is.


  • In "INorder" the root node is "IN" the middle of left and right nodes

  • In "PREorder" the root node is "PRE" i.e. before the left and right nodes

  • In "POSTorder" the root node is "POST" i.e. after the left and right nodes



This was that proverbial duhh moment :)

1 comment :

Anonymous said...

Good post and this mail helped me alot in my college assignement. Thank you on your information.