title: binary tree level wise print function not working
body: <p>i need to create a function that prints level wise binary tree with its children for eg input is 1 in root its 2 children left is 10 , right is 12
  then output will be like - 1:L:10,R:12 (then endl)  2:L:-1,R:-1 (then endl)  3:L:-1,R:-1 and so on level wise i do not know why my code is running infinite times thus giving time limit exceed error
  if anyone could take a look</p>
  
  <pre><code>    #include&lt;queue&gt;
  void printLevelWise(BinaryTreeNode&lt;int&gt; *root) {
  if(root==NULL) return;
  queue&lt;BinaryTreeNode&lt;int&gt;*&gt;q;
  q.push(root);
  while(q.size()!=0){
  BinaryTreeNode&lt;int&gt; *front=q.front();
  cout&lt;&lt;front-&gt;data&lt;&lt;":";
  q.pop();
  
  if(root-&gt;left!=NULL) {
      cout&lt;&lt;"L:"&lt;&lt;root-&gt;left-&gt;data;
      q.push(root-&gt;left);
  }
  else{
  cout&lt;&lt;"L:-1";  
  }
  
  if(root-&gt;right!=NULL){
      cout&lt;&lt;",R:"&lt;&lt;root-&gt;right-&gt;data; 
      q.push(root-&gt;right);
       }
  else{
  cout&lt;&lt;",R:-1";  
  }
  
  cout&lt;&lt;endl;
  }
  
  }
  </code></pre>