0

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.


1 Answers1

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