Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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;

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;

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Mining Concepts And Techniques

Authors: Jiawei Han, Micheline Kamber, Jian Pei

3rd Edition

0123814790, 9780123814791

More Books

Students also viewed these Databases questions

Question

4. What action should Cherita Howard take and why?

Answered: 1 week ago