Skip to main content

Posts

Showing posts with the label level order

Tree traversals-Very Important Basics in Trees

Question: Inorder Traversal Algorithm:  Left-Root-Right CODE: class Node {     int data;     Node left, right;    Node(int item)    {         data = item;         left = right = null;     } }  class Solution {     /* Prints preorder traversal of Binary Tree.  In output       all keys should be separated by space. For example       preorder traversal of below tree should be "10 20 30"          10        /      \      20       30 */      void inOrder(Node root)     {        // Your code goes here        if(root==null){return;}        inOrder(root.left);        System.out.print(root.data+" ");        inOrder...