Bookmark Topic Watch Topic
  • New Topic

Need urgent help with tree  RSS feed

 
Emili Calonge
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Report post to moderator
First of all, sorry I've double posted(also in intermediate), but O really need to solve this before friday. Second, I'm not English so it may be quite difficult for me to explain exactly what my problem is, so I'll try to make it clear.

Ok, I'm first going to explain what I'm trying to do:
I'm writing this program where a user can add thousands of files(pictures), the objective of the program is to give a powerful search engine that finds "fast" the files wanted by the user. The part I'm wornking on now is search based on file size, I'm doing it whith AVL trees because this way I can easily search with querys like "size < 200".

Now the second part, the problem(I don't know if the sames names are given in English, I work with Nodes wich have a value, a right son and a left son):
I'm doing the add function to the tree recursively, but I've got lots of problems always with the same thing. I want to add a file to the tree, so I want to do it this way:
if(empty){
create Node
}else{
add(tree.right_son(),file)
}
Obviously this is not my java code, in case someone is going to tell me this is not java syntax.
The problem comes when tree.right_son() returns empty, it gives a NullPointer Exception, I know I could check if it is empty before calling the right_son() function, but I've got lots of function calls like this. What I need is being able to call a function with a null and then checking inside the function if the parameter is null, is there any way to do this, or does anybody know how to do this??

My real problem is that I'm "translating" this function in one I've got writen in C++, and that I have no time to do this, so any help will be really appreciated. Thanks a lot.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 37507
552
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Report post to moderator
Note that we ask people not to cross post. It's pretty much the same people who read posts in both forums and invites repeated discussion. Please continue discussion in intermediate.
 
    Bookmark Topic Watch Topic
  • New Topic
Boost this thread!