Java Reference
In-Depth Information
Implement a 2d-tree, providing at least a method to insert a new point and a method to test whether a given
point is in the tree.
FIGURE 25-15
The steps in creating a 2d-tree for five given points
(50, 40)
(50, 40)
(50, 40)
(40, 70)
(40, 70)
(80, 20)
100
100
100
50
50
50
0
0
0
0
100
50
0
100
0
100
50
50
(d) After inserting (90, 10)
(e) After inserting (60, 30)
(50, 40)
(50, 40)
(40, 70)
(80, 20)
(40, 70)
(80, 20)
(90, 10)
(60, 30)
(90, 10)
100
100
50
50
0
0
100
100
0
50
0
50
A NSWERS TO S ELF -T EST Q UESTIONS
1.
As the left child of the node that contains Whitney .
2.
No. The constructor first calls the default constructor of BinaryTree , which sets root to null . The method
setRootData contains the call root.setData(rootData) , which would cause an exception.
Search WWH ::




Custom Search