Question: For this question assume that binary search tree treeA (with root referenced by rootA as shown above) has been declared and instantiated as an object
For this question assume that binary search tree treeA (with root referenced by rootA as shown above) has been declared and instantiated as an object of a class that correctly implements BSTInterface. What is the output of each of the following code sections (these sections are independent; that is, you start over again with the tree as shown in the figure above for each section):
a.
System.out.println(treeA.isFull());
System.out.println(treeA.isEmpty());
System.out.println(treeA.size());
System.out.println(treeA.min());
System.out.println(treeA.max());
System.out.println(treeA.contains('R'));
System.out.println(treeA.remove('R'));
System.out.println(treeA.remove('R'));
System.out.println(treeA.get('S'));
b.
Iterator
iter = treeA.getIterator(BSTInterface.Traversal.Preorder);
while (iter.hasNext()) System.out.print(iter.next());
System.out.println();
for (Character ch: treeA)
System.out.print(ch);
System.out.println();
iter = treeA.iterator();
while (iter.hasNext())
System.out.print(iter.next());
c.
Iterator
iter = treeA.getIterator(BSTInterface.Traversal.Preorder);
treeA.remove('N'); treeA.remove('R');
while (iter.hasNext())
System.out.print(iter.next());
iter = treeA.getIterator(BSTInterface.Traversal.Inorder);
while (iter.hasNext())
System.out.print(iter.next());
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
