V
V
Ventus2019-12-12 12:27:42
recursion
Ventus, 2019-12-12 12:27:42

Can there be two base cases in a recursion?

I solved the problem with recursion, but I had two base cases (two if s ). Is such a construction correct?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
maaGames, 2019-12-12
@Ventus

The instructor tricked you with the term "base case", there is no such term in common use (in recursion).
There can be any number of conditional statements (usually, at least one).
Correctness of the solution != optimality of the solution. Therefore, any code can be considered "correct" if it gives the correct solution to the problem, taking into account the terms of reference.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question