• Courses
  • Tutorials
  • DSA
  • Data Science
  • Web Tech
June 08, 2022 |164.9K Views

Tree Traversals

Description
Discussion

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.
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.


Tree Traversals: https://www.geeksforgeeks.org/tree-traversals-inorder-preorder-and-postorder/