Question: Given two pointers to the root nodes of two different, unbalanced, binary search trees (TreeNode * ptr), write a function compare to determine if
Given two pointers to the root nodes of two different, unbalanced, binary search trees (TreeNode * ptr), write a function "compare" to determine if the two trees contain the same values. You may assume each node has a data section and left, right and parent pointer, but may not assume any other items exist in the nodes. Your solution should be as efficient as possible both in terms of space and time complexity.
Step by Step Solution
3.47 Rating (154 Votes )
There are 3 Steps involved in it
To compare two binary search trees efficiently we can pe... View full answer
Get step-by-step solutions from verified subject matter experts
