This post is completed by 1 user
|Add to List|
Check if Two BST's are Identical
Objective: Given Two binary Search Trees, Check if both are identical.
Input: Two binary Search Trees
- Traverse both trees at the same time, starting from the root.
- Check if roots are not null and data are matched, if not, return false.
- Make recursive calls to root.left and root.right.
- If any of the trees gets over and other is not, return false.
- if both traversals of both trees end at the same time, return true
- see code.
- Maximum difference between two elements where larger element appears after the smaller element Medium