Hi, I'm attempting to construct an AVL Tree data structure in java. I have the tree built and I am absolutely sure the tree is constructing correctly. I am having trouble getting my retrieve method to work which should find and return a node in the tree. So far the method works only if the node I am trying to retrieve is the root node. Here is the method:
public Book getBook(String title) {
private Book retrieve(Book current, String title) {
while(current!=null)
if (((String)current.name).compareTo(title)< 0)
}
public Book getBook(String title) {
return retrieve(root, title);
}private Book retrieve(Book current, String title) {
while(current!=null)
if (((String)current.name).compareTo(title)< 0)
return retrieve(current.left, title);
else if (((String)current.name).compareTo(title)>0) return retrieve(current.right, title);
else return current;
return null;}