0

What is Base case

Why base case is necessary

25th Aug 2021, 5:56 AM
Vikalp Monas
Vikalp Monas - avatar
6 Answers
+ 5
Hello there, the base case usually exists in an if statement where you don't return the function. Here's an example in C#: int Factorial(int number) { // base if (number <= 1) return 1; return number * Factorial(--number); } Console.Write(Factorial(5)); // 120 The recursion doesn't end until the number reaches the base case.
25th Aug 2021, 6:56 AM
Tim
Tim - avatar
+ 5
The base case exists to terminate the recursion. Without base case the recursion will continue infinitely.
25th Aug 2021, 6:01 AM
你知道規則,我也是
你知道規則,我也是 - avatar
+ 2
Now I am clear with this concept, thank you
25th Aug 2021, 7:16 AM
Vikalp Monas
Vikalp Monas - avatar
+ 2
Base case is necessary because In The absence of base case ur loop will run infinite
27th Aug 2021, 12:43 AM
Vaishnavi Gupta
0
Can you Tell base case in this problem
25th Aug 2021, 6:03 AM
Vikalp Monas
Vikalp Monas - avatar
0
Vikalp Monas If you can detail more about the question.
25th Aug 2021, 6:10 AM
你知道規則,我也是
你知道規則,我也是 - avatar