Show Buttons
Share On Facebook
Share On Twitter
Share On Google Plus
Share On Linkdin
Share On Pinterest
Share On Reddit
Share On Stumbleupon
Contact us
Hide Buttons

Check if Two BST’s are Identical

Objec­tive: Given Two binary Search Trees, Check if both are identical.

Input: Two binary Search Trees

Check if Two BST's are Identical

Check if Two BST’s are Identical


  • Trav­esre both trees at the same time, start­ing from root.
  • Check if roots are not null and data are matched, if not, return false.
  • Make recur­sice calls to root.left and root.right.
  • If any of the tree gets over and other is not , return false.
  • if both tra­ver­sal of both trees ends at the same time, return true
  • see code.

Com­plete Code:



You may also like...