Advertisement
Neveles

© 2020 Neveles. All rights reserved.

Mar 30th, 2020
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.59 KB | None | 0 0
  1. bool isEqualTree(const BinarySearchTree<T>& other)
  2.   {
  3.     if (other.getCount() != getCount())
  4.     {
  5.       return false;
  6.     }
  7.     else
  8.     {
  9.       QueueList<Node<T>*> queue;
  10.       queue.enQueue(root_);
  11.       while (!queue.isEmpty())
  12.       {
  13.         Node<T>* temp = queue.deQueue();
  14.         if (other.iterativeSearch(temp->key_) == false)
  15.         {
  16.           return false;
  17.         }
  18.         if (temp->left_ != nullptr)
  19.         {
  20.           queue.enQueue(temp->left_);
  21.         }
  22.         if (temp->right_ != nullptr)
  23.         {
  24.           queue.enQueue(temp->right_);
  25.         }
  26.       }
  27.       return true;
  28.     }
  29.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement