| | | | | |

BST Recursive Methods

  template <typename T, class P = TLessThan<T> >
  class BST // or class BSTLite
  {
  public:
    size_t   Size        ()    const { return RSize(root_); }
    int      Height      ()    const { return RHeight(root_); }
    void     Clear       ()
    {
      RRelease(root_);
      delete root_;
      root_ = 0;
    }
    template < class F >  // function class
    void Traverse        (F f) const { RTraverse(root_,f); }

  protected:
    static size_t RSize     (const Node * n);
    static int    RHeight   (const Node * n);
    static void   RRelease  (Node* n);
    static Node*  RClone    (const Node* n);
    template < class F >
    static void   RTraverse (Node* n, F f);
  };

| | Top of Page | 12. Binary Search Trees - 18 of 27