By : user2952739
Date : November 19 2020, 01:01 AM

hope this fix your issue If the trees are not balanced, or the result shouldn't be balanced that's quite easy: code :
without loss of generality  let the first BST be smaller (in size) than the second.
1. Find the highest element in the first BST  this is done by following the right son while it is still available. Let the value be x, and the node be v
2. Remove this item (v) from the first tree
3. Create a new Root with value x, let this new root be r
4. set r.left = tree1.root, r.right = tree2.root
Share :

Filling empty Binary tree as Binary search tree without changing structure (Node linkage)
By : Michelle
Date : March 29 2020, 07:55 AM
wish helps you Not only is your solution correct, it's impossible to do better (in the asymptotic sense), assuming that only < or > comparisons are allowed between data items. Your solution involves sorting the data, which takes time O(n log n), and then inserting it into the tree in an inorder traversal, which takes time O(n), for an overall time complexity of O(n log n). Notice that after building a binary search tree, we can read out all its data in sorted order using an inorder traversal  that is, solving the interviewer's problem can be used to sort any given sequence of data elements.

Serializing a generic binary search tree with a bunch of child objects, including a binary tree
By : Rohit J
Date : October 31 2020, 09:54 AM
this one helps. My Add() method in the binary tree had an unnecessary check before inserting elements, thus, it prevented elements of the outer tree from being inserted.

Is binary tree a binary search tree if tree is spread over multiple machines
By : Masadul
Date : March 29 2020, 07:55 AM
around this issue BST has a property. it's each children will also be a BST. validate all the machine's binary tree and once you have the each machine BT is BST then get the root node of each machine's BT and then again validate the tree if it is BST from the root node.

How to make a Binary Search Tree a Complete Binary Search Tree in Java?
By : Kolsoum Abbaszadeh
Date : March 29 2020, 07:55 AM

Differences in implementation of a tree, binary tree and, binary search tree in python
By : Darvish
Date : March 29 2020, 07:55 AM
it fixes the issue a tree , each node can have any number of children, and it certainly doesnt need to be balanced.



Related Posts :
