Two balanced binary trees are given with m and n elements respectively. They can be merged into a balanced binary search tree in ____ time.
Two balanced binary trees are given with m and n elements respectively. They can be merged into a balanced binary search tree in ____ time. Correct Answer O(m+n)
First we store the in-order traversals of both the trees in two separate arrays and then we can merge these sorted sequences in O(m+n) time. And then we construct the balanced tree from this final sorted array.
মোঃ আরিফুল ইসলাম
Feb 20, 2025