BT Interview Question
Software Engineer / DevelopersCountry: India
Interview Type: In-Person
I think the simplest approach would be to take one tree as base, and read (using any traversal) data from the other tree and insert into the base tree. Effectively you will end up merging the two trees.
Do inOrder Traversal of both the BSTs and u'll get 2 sorted arrays (and elements are unique)..so merge these 2 sorted arrays using Merge Sort and there u go :)
- Karthik Vvs November 17, 2012