+ 1

What is base case?

4th Aug 2016, 2:27 PM
subha21
9 Antworten
+ 8
The base case is a piece of code that allows us to end a recursive function. void func(int x) { if (x == 0) return... else { cout << x func(--x) } The base case here is the if (x == 0), as that is the function which will eventually allow us to exit a recursive function. Without a base case, the function will infinitely loop and not end.
4th Aug 2016, 2:56 PM
Cohen Creber
Cohen Creber - avatar
+ 3
means its a condition to end the process
4th Aug 2016, 2:59 PM
subha21
+ 2
Please elaborate on your question. Post some code, or explain what your question is.
4th Aug 2016, 2:30 PM
Cohen Creber
Cohen Creber - avatar
+ 2
whay do you mean by the word base case
4th Aug 2016, 2:48 PM
subha21
+ 2
best case is a exit condition for recursion
14th Aug 2016, 4:55 AM
Pavatharini.M
+ 1
Subha good question.important.
5th Aug 2016, 7:52 AM
‎‏‎‏‎Joe
‎‏‎‏‎Joe - avatar
+ 1
Base case is like the last iteration of the recursive function. The end or final "go round".
5th Aug 2016, 7:54 AM
‎‏‎‏‎Joe
‎‏‎‏‎Joe - avatar
0
xx.
12th Nov 2016, 8:37 AM
Lynette Lee-Ann Everson
Lynette Lee-Ann Everson - avatar
- 1
ok i will try to elaborate give me some time
4th Aug 2016, 2:36 PM
subha21