title: print ancestor nodes in a binary tree for given input node without using recursion in java
body: <p>How to get the ancestor nodes for a binary tree without recursion.I have the below code using recursion,but couldn't figure out on how to get without using recursion.</p>
  
  <pre><code>boolean printAncestors(Node node, int target) {        
      /* base cases */
      if (node == null) {
          return false;
      }
  
      if (node.data == target) {
          return true;
      }
  
      /* If target is present in either left or right subtree of this node then print this node */
      if (printAncestors(node.left, target) || printAncestors(node.right, target)) {
          System.out.print(node.data + " ");
          return true;
      }
  
      /* Else return false */
      return false;
  }
  </code></pre>