Check if Two BST’s are Identical

Objective: 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


  • Travesre both trees at the same time, starting from root.
  • Check if roots are not null and data are matched, if not, return false.
  • Make recursice calls to root.left and root.right.
  • If any of the tree gets over and other is not , return false.
  • if both traversal of both trees ends at the same time, return true
  • see code.

Complete Code:



Top Companies Interview Questions..-

Google Microsoft Amazon Facebook more..

If you find anything incorrect or you feel that there is any better approach to solve the above problem, please write comment.

You may also like...

%d bloggers like this: