@@ -0,0 +1,1373 @@
+package com.sunny.grokkingalgorithms.fasttrack.treesandgraphs;%0A%0Aimport com.sunny.grokkingalgorithms.ctci.c4.util.BinaryTreeNode;%0Aimport com.sunny.grokkingalgorithms.ctci.c4.util.TreeUtils;%0A%0A/**%0A * Created by sundas on 6/11/2018.%0A */%0Apublic class ConstructATreeFromPreOrderAndInorderTraversals %7B%0A%0A  /*%0A  Construct a tree using pre order and inorder traversa;s%0A   */%0A%0A  static int preOrderIndex = 0;%0A%0A  /**%0A   *%0A   * @param inorder%0A   * @param preOrder%0A   * @param start%0A   * @param end%0A   * @return%0A   */%0A  public static BinaryTreeNode createBTree(int%5B%5D inorder,int%5B%5D preOrder,%0A                                           int start,int end)%7B%0A    if(start %3E end)%7B%0A      return null;%0A    %7D%0A    int i;%0A    for(i = start; i %3C= end ; i++)%7B%0A      if(preOrder%5BpreOrderIndex%5D == inorder%5Bi%5D)%7B%0A        break;%0A      %7D%0A    %7D%0A    BinaryTreeNode node = new BinaryTreeNode();%0A    node.data = preOrder%5BpreOrderIndex++%5D;%0A    node.left = createBTree(inorder,preOrder,start,i-1);%0A    node.right = createBTree(inorder,preOrder,i+1,end);%0A    return node;%0A  %7D%0A%0A  /**%0A   *%0A   * @param args%0A   */%0A  public static void main(String%5B%5D args) %7B%0A    int inorder%5B%5D  = %7B-7,-6,-5,-4,-3,-2,1,2,3,16,6,10,11,12,14%7D;%0A    int preorder%5B%5D = %7B3,-2,-3,-4,-5,-6,-7,1,2,16,10,6,12,11,14%7D;%0A    BinaryTreeNode root = createBTree(inorder,preorder,0,inorder.length - 1);%0A    TreeUtils.performBfsLevelMarker(root);%0A  %7D%0A%0A%0A%7D%0A

Constructing a tree given an inorder traversal and preorder tarversal.