• Some users have recently had their accounts hijacked. It seems that the now defunct EVGA forums might have compromised your password there and seems many are using the same PW here. We would suggest you UPDATE YOUR PASSWORD and TURN ON 2FA for your account here to further secure it. None of the compromised accounts had 2FA turned on.
    Once you have enabled 2FA, your account will be updated soon to show a badge, letting other members know that you use 2FA to protect your account. This should be beneficial for everyone that uses FSFT.

AVL Tree in Java

sqeezon

n00b
Joined
Sep 22, 2006
Messages
16
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) {
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;
}
 
Back
Top