title: print boundary of binary tree
body: <p>How to print the outside frame of a binary tree.</p>
  
  <ol>
  <li>the order is top to down, left to right, then down to top</li>
  <li>print all leftest node and rightest nodes</li>
  <li>print all leaf nodes</li>
  <li><p>print all nodes which only have 1 leaf</p>
  
  <pre><code>         100
          /   \ 
        50     150
       / \      /
     24   57   130
    /  \    \    \
  12   30    60   132
  </code></pre></li>
  </ol>
  
  <p>e.g:
  the output should be
  100, 50, 24, 12, 30, 57, 60, 130, 132, 150</p>
  
  <p>If we write three different functions to print left nodes, leaf nodes and right nodes, it can be easily solved but it takes O(n+2logn) time.</p>
  
  <p>I am also looking for an O(n) approach but condition is that each node should be visited only once, dont want this extra O(2logn) part.</p>