Rekursioonikõne
Rekursioonikõne, or recursive call, is a programming concept where a function calls itself within its own definition. This self-referential nature allows for elegant solutions to problems that can be broken down into smaller, self-similar subproblems. A recursive function typically has two main parts: a base case and a recursive step. The base case is a condition that stops the recursion, preventing an infinite loop. Without a base case, the function would repeatedly call itself indefinitely, leading to a stack overflow error. The recursive step is where the function calls itself with modified input, moving closer to the base case. Common examples of problems solved with recursion include calculating factorials, traversing tree structures, and implementing algorithms like quicksort and mergesort. While recursive solutions can be concise and conceptually clear, they can sometimes be less efficient in terms of memory usage and execution speed compared to iterative solutions due to the overhead of function calls. Understanding how to identify base cases and design recursive steps is crucial for effective use of this programming technique.