Skip to main content

Posts

Showing posts from June, 2020

Program to Implement recursive and Iterative Binary Tree Traversal – Preorder, InOrder and Postorder

Given a Binary tree, Traverse it using DFS using recursion. Therefore, the Depth First Traversals of this Tree will be: (a) Inorder   (Left, Root, Right)  (b) Preorder  (Root, Left, Right)  (c) Postorder (Left, Right, Root)       public class DFSTraversalUtility     {         public static void PreOrder(TreeNode root)         {             if (root != null )             {                 Console.Write(root.Data + " " );                 PreOrder(root.Left);                 PreOrder(root.Right);   ...