Question: ADT Table implemented as Binary Search Tree in JAVA. Need help with the following methods: Search -- Given a key, return that key's data item

ADT Table implemented as Binary Search Tree in JAVA. Need help with the following methods:

Search -- Given a key, return that key's data item

getSize -- Return # of nodes

getHeight -- Return the tree's height

getAvgLevel -- Return the avg level of the nodes in the tree

showTree -- Display the elements of the tree (with the appearance of a 'tree')

toString -- Display all the elements in the the table in accordance to key's order (ascending order)

Define a Table class for the whole tree and a Node class for each node in the tree. Must use recursion for operations. Use an Comparable interface. Here is my interface and node class:

interface Comparable { public int compareTo ( Comparable other ); // return -1 if les than other, 0 if equal, and +1 if greater than public String toStringKey(); //return a short string to summarize the items, use for showTree }

class Node { public Comparable data; public Node left; public Node right; }

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!