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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started