Advertisement
JoeQiao

Untitled

Feb 20th, 2017
3,360
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. template <class bstdata>
  2. BST<bstdata>::BST():root(NULL){};
  3.  
  4. template <class bstdata>
  5. BST<bstdata>::~BST(){
  6.     destructorHelper(root);
  7. }
  8.  
  9.  
  10. template<class bstdata>
  11. void BST<bstdata>::destructorHelper(NodePtr root)
  12. {
  13.     if(!root->left)
  14.         destructorHelper(root->left);
  15.     if(!root->right)
  16.         destructorHelper(root->right);
  17.     if(root!=NULL)
  18.         delete root;
  19. }
  20. template <class bstdata>
  21. bool BST<bstdata>::isEmpty()
  22. {
  23.     if(root==NULL)
  24.         return true;
  25.     else
  26.         return false;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement