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
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