-3
I have a function that is called recursively, how to avoid memory bursting ??
int cont = 0;
public void recur() {
recur();
cont ++;
System.out.println("Chamado: " + cont);
}
-3
I have a function that is called recursively, how to avoid memory bursting ??
int cont = 0;
public void recur() {
recur();
cont ++;
System.out.println("Chamado: " + cont);
}
3
You need an output criterion for recursion.
Yes. Just that. Putting that there will be no pile burst
Indeed, it would be appropriate to also have a proof/proof/proof/conjecture that the base case of recursion is reached
There’s a way out, but basically it’s almost infinite.
2
You will need to add an output clause. For example checking if Count == 10,000.
Another option that can happen naturally is that the machine will run out of memory, or if it has TOO much memory, the value of Count may be greater than the maximum value of Integer. [Integer.MAX_VALUE]
Thus, if each recursive function occupies a single byte of memory (occupies much more, in fact), you would use 2GB only to reach that level of recursive call depth. I think to assume this value of the whole maximum was to stretch and very the ballast...
Browser other questions tagged java
You are not signed in. Login or sign up in order to post.
Related: https://answall.com/q/237151/64969
– Jefferson Quesado
What are you trying to do with that?
– Victor Stafusa
Basically I take all the links from one page, and then I call the function to pick up all the links from each page of each link, and so recursively.
– Lucas Caresia
@Lucascarezia you can do this with navigation on graphs, but this is subject for another question
– Jefferson Quesado