Lesson 15 of 23
Recursion
10 min 30 XP
Recursive function लहान input सह स्वतःलाच call करते. Base case नसेल तर stack overflow होतो आणि प्रोग्राम crash होतो.
Example: edit me and press Run
Output Loading C (first time takes a few seconds)
Press Run to see the result here.Recursive fib(40) खूप धीमे आहे (O(2ⁿ)); loop किंवा memoization ते O(n) करते. Interviewers ना ही तुलना खूप आवडते.