1.

Explain about Inorder, Preorder and Postorder traversals?

Answer»

Unlike linear data structures (ARRAY, Linked List, Queues, STACKS, etc) which have only one logical WAY to traverse them, trees can be TRAVERSED in different ways. Following are the generally used ways for traversing trees.



Example Tree

Depth First Traversals:
(a) Inorder (Left, ROOT, Right) : 4 2 5 1 3
(b) Preorder (Root, Left, Right) : 1 2 4 5 3
(c) Postorder (Left, Right, Root) : 4 5 2 3 1

Breadth First or Level Order Traversal : 1 2 3 4 5
Please see this post for Breadth First Traversal.



Discussion

No Comment Found