Class "Binary search tree". Complete the class by including the division method object of class "Binary search tree" on two objects of the class "Binary tree search ". The key to division must be the value of the item being requested software and is passed as an argument method. Items smaller than the key in value, should be placed in the first tree as well elements, and larger - in the second.
Asked
Active
Viewed 204 times
0
-
Which one is it, C++ or Python? – Sean Jun 10 '20 at 11:21
-
Does this answer your question? [Split a binary search Tree](https://stackoverflow.com/questions/43752944/split-a-binary-search-tree) – Philipp H. Jun 10 '20 at 11:24
-
I don't understand how to divide an object of one search engine tree into two objects of search engine tree. – Алекс Миччел Jun 10 '20 at 11:32
1 Answers
0
Just trying to put an algorithm around the question, may be it helps to get the requirement more clear
//your initial object is obj; you have [root,left,right] in your object; assign your left sub-tree to the new first object;
obj1=obj.left;
//then set the left sub-tree of your initial object to NULL
obj.left=NULL;
//assign remaining tree to new second object
obj2=obj;
Will that help?

lorenz
- 178
- 2
- 10
-
The essence of the task is this. For example, there is a binary search engine consisting of 30 elements. This binary tree has a root, parents and descendants. For a program request, take a specific descendant. From it make a binary search tree. For example, 30 is the root, it has two objects 20 and 25, respectively, they have their descendants, for example, 20 (10 and 15), and 25 (18 and 22). These descendants have parents of other objects, etc. .. I am taking an object, for example 20. From its descendants 10 and 15 I make two binary search trees. – Алекс Миччел Jun 10 '20 at 13:15