DEV Community

Discussion on: A Simple introduction to recursion

 
dakujem profile image
Andrej Rypo

Well, if you're asking... It's curious you did not use the ever-present factorial example. The example provided does not really demonstrate the advantage of recursion. I'd use an example that would otherwise require a stack data structure, like an algo to detect palindromes, for example.

abcba --> true
abcde --> false
Enter fullscreen mode Exit fullscreen mode
Thread Thread
 
anwarr_________ profile image
Anwar

Yeah that's because the goal of writing this article was to clarify the main idea of recursion for absolute beginners, I wanted to make it as simple as possible so I came up with this simple example, maybe in an upcoming article I'll dive more deep into recursion
Thanks for your opinion