DEV Community

Cover image for A Simple introduction to recursion

A Simple introduction to recursion

Anwar on November 01, 2020

Recursion is one of the topics that confuses people when seeing it for the first time, this article introduces the main idea of recursion in order...
Collapse
 
dakujem profile image
Andrej Rypo • • Edited

Chapter one: Tail Recursion.

To understand tail recursion, you need to understand Chapter One: Tail Recursion.

Collapse
 
anwarr_________ profile image
Anwar •

This link goes to this article not an article about tail recursion

Collapse
 
dakujem profile image
Andrej Rypo •

Come on, man, it's a joke! I updated the link...

Thread Thread
 
anwarr_________ profile image
Anwar •

I'm pretty slow at getting jokes, I have just got it now, great one bro😂😂😂

Thread Thread
 
anwarr_________ profile image
Anwar •

liked the article ?

Thread Thread
 
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
Collapse
 
hamzamateen profile image
HamzaMateen • • Edited

I think people should first learn how stacks work as function call always endup being on the call stacks. This way we can more rigorously define Recursion in terms of implementation.

Nice article tho!! ❤️❤️

Collapse
 
anwarr_________ profile image
Anwar •

Yeah you're right, generally you understand your code better when you learn more about how it works and what happens behind the scenes

Thank a lot bro ❤️️

Collapse
 
almasweb1 profile image
Almas Rakhmatullaev •

Good article! I didn't really understand what recursion is yesterday, but after this article I began to understand well. Thank you.

Collapse
 
anwarr_________ profile image
Anwar •

Thank a lot man glad I could help

Collapse
 
anwarr_________ profile image
Anwar •

your so welcome, thank you for this great feedback :)