title: Build binary tree from level order & inorder tree traversal
body: <p>I have been preparing for an interview and came across this question:
  Q. Build a binary tree from level order &amp; inorder tree traversal.</p>
  
  <p>Can someone guide me in this regard. I have been struggling with formulating the algorithm for long time now.</p>
  
  <p>Here is the code I wrote:</p>
  
  <pre><code>struct node * buildLevelInTree(int * in, int * Level, int inStart, int inEnd, int level){
  
  static int levelIndex=0;
  
  struct node * root=newNode(Level[levelIndex++]);
  
  //node has no child
  if(inStart==inEnd)
          return root;
  
  int inIndex=searchIndex(in,inStart,inEnd,root-&gt;data);//search index of root in inorder traversal
  
  //Note the use of level to take the next root from level order traversal
  root-&gt;left=buildLevelInTree(in,Level,inStart,inIndex-1,2*level+1);
  if(root-&gt;left!=NULL)
  root-&gt;right=buildLevelInTree(in,Level,inIndex+1,inEnd,2*level+2);
  else
  root-&gt;right=buildLevelInTree(in,Level,inIndex+1,inEnd,2*level+1);
  return root;
  
  }//end of buildLevelInTree
  </code></pre>
  
  <p>Thanks a ton!</p>