aspose file tools
The moose likes Beginning Java and the fly likes Recursion FindPath[solved] Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "Recursion FindPath[solved]" Watch "Recursion FindPath[solved]" New topic
Author

Recursion FindPath[solved]

David Delgado
Greenhorn

Joined: Sep 19, 2010
Posts: 6
Solved, thank you!
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 35256
    
    7
Hard to say what's happening without seeing the canFlowOffMap method.


Android appsImageJ pluginsJava web charts
David Delgado
Greenhorn

Joined: Sep 19, 2010
Posts: 6
Sorry,

Actually it was meant to be canFindPath (I changed name). I'm making recursive calls to itself.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 35256
    
    7
If any of the recursive calls ever return "true", then you should not recurse any further, but return straight back up the call stack. As it is, you're ignoring the returned value, and continue to look for solutions in other directions.
David Delgado
Greenhorn

Joined: Sep 19, 2010
Posts: 6
Thank you for replying. So then I need to put if statements inside my check N/W/S/E loops to check if the program returned true?? That's what I was thinking of earlier this morning but wasn't sure. Should I use a local variable to keep track of the boolean?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 35256
    
    7
The easiest may be to replace "canFindPath(...)" by "if (canFindPath(...)) return true" or something like that.
David Delgado
Greenhorn

Joined: Sep 19, 2010
Posts: 6
Thank you Uff, that solved my problem.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 32712
    
    4
Don't go and edit your first post

Now people who read this thread can't understand what the question was about, and the replies all read as nonsense.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19216

I'd go further and ask you not to edit any post that has been replied to, because of the same reason.


SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 35256
    
    7
Indeed, I feel like I helped someone who was not supposed to ask for help with his homework.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Recursion FindPath[solved]
 
Similar Threads
JInternalFrame with glass pane
datasource look up problem
geting only l;ast vale from hashmap
Creating exe in java...
Where I have to mention my template in XML?