Question: Help ASAP amal 1o Hdng Sub A 2D treeis a binary search tree in which each node contains a 2D point and holds the x

Help ASAP  Help ASAP amal 1o Hdng Sub A 2D treeis a binary
search tree in which each node contains a 2D point and holds
the x and y coordinates of that node. 20 tree generalizes abinary
search tree in that it positions eachnode accordingto eitherthe xor y coordinates
of its data point. The coordinate choice depends onthe level at which
the node is addedinto the tree. The first point you add into

amal 1o Hdng Sub A 2D treeis a binary search tree in which each node contains a 2D point and holds the x and y coordinates of that node. 20 tree generalizes abinary search tree in that it positions eachnode accordingto eitherthe xor y coordinates of its data point. The coordinate choice depends onthe level at which the node is addedinto the tree. The first point you add into an empty tree is placed nto a node that becomes the tree's root. IFthe next point to be added has an x-coordinate that is less than the x-coordinate of the point in the root, you place the new point into the left child of the root. Otherwise, you place it into root's right child Insertions at the next level-level 3-compares y-coordinates; insertion at level 4 compares x-coordinates, and so on. For example, suppose we want to addthe points (50,40),(40,70)(80,20),(90,10), and (60,30) into an initially empty 2d tree (the process is illustrated below) . The first point becomesthe root node . To add (40,70), you compare 40, the point's x-coordinate, with 50, the x-coordinate of theroot. Since 40 is less than0 you moveto the left. The left child of root is null so the new point goes into the left chid of the root. To add (80,20), you compare 80 with 50, the x-coordinates of the root node. Since 80 ts greater than 50, you move to the right. The night child of the root is null, so new node (80,50) is placed into the right child of the root. . To add the next point, (90,10), you compare 90 with the x-cocrdinate of the root node. 90 is greaterthan 50, so you move to the right child and compare the y-coordinate with the right child 10 is less than 20, the y-coordinate of the root's right child. Hence, youmove to the left The left child of (80,20) is nulil, hence, the new node (90,10) is added as the left child of (e0,20) . To add the next point (60,8), you compare 60 with x-coordinate of the root. 60 is greatertharn 50, so youmove to the right. Then you compare the y coordinates of (60,8) with y-coordinate of

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!