title: c++ data structures heaps
body: <p>I've been trying to implement a heap into my program. It seems to me that heaps are the same as binary trees. Is this the case with all heaps such as min heap and max heap since all that is being done is a traversal through the tree putting the largest/smallest node to the top?</p>
  
  <p>Also, I've read that using 1-D arrays are only beneficial when we have a complete binary tree. If we don't have a complete binary tree, it would be more beneficial to use class that is a friend class to another? Why is that? Such as:</p>
  
  <pre><code>template&lt;class T&gt; class BT; // forward declartion -&gt; added at edit
  
  template&lt;class T&gt;
  class BTNode{
      friend class BT&lt;T&gt;; // not sure why we need two classes
  private:
      T data;
      BTNode&lt;T&gt; *leftChild; // what is the benefit of making a object Node?
      BTNode&lt;T&gt; *rightChild;
  };
  
  template&lt;class T&gt;
  class BT{
  private:
      BTNode&lt;T&gt; *root; // what is the benefit of having this root in another class?
  };
  </code></pre>
  
  <p>Thank you in advance.</p>