Which of the following is the more effective use of recursion?
void recurse() {
if (a%b == 0){
i++; // some int
recurse();
}
}
OR
void recurse() {
if (a%b != 0)
return;
i++;
recurse();
}
Should the choice depend entirely on how likely a%b == 0 is to evaluate to true? Or are there other factors at play here that affect performance?
Aucun commentaire:
Enregistrer un commentaire