Recursive method and memory problems
I am implementing the DFS algorithm and I am keeping track of what routes have been passed and their value, the core of the algorithm looks like this:
the problem is, if the network is searching down a path and ends in a dead at the function returns at the place of my comment, but the
length
variable has been forgotten by the program (atleast what i think) because this method has been called multiple times already and is now returning to an older instance of itself. So is there any way to surpass this issue?
Nodes are planets and Edges are Routes.5 Replies
@TeBeCo
Unknown User•11mo ago
Message Not Public
Sign In & Join Server To View
hmm returning a value wouldnt be handy, because it generally needs to forget the when it finds a dead end and grab the one it was working on before that branch.
but thank you
Unknown User•11mo ago
Message Not Public
Sign In & Join Server To View
I just fed the nodes ive been at to the method itself using its params, so i didnt have to return anything but it did keep track of old data when it popped