DEV Community

Cover image for Using Recursion like a Pro - 1
YuehBen66
YuehBen66

Posted on

Using Recursion like a Pro - 1

Why I write this post ?

In order to be a better programmer,
getting a dream software job,
all developers must face the devil call "Algorithms",
especially something called "Recursion" really showed me how DESPERATION looks like 😵‍💫😵‍💫😵‍💫.

 

After struggling for a while,
I search for "How to use Recursion comfortably",
and finally found a book called Think like a programmer.

Think Like a programmer book

 

This book really SAVED MY LIFE !!! 🥳🥳🥳,
and now I can use Recursion pretty comfortably,
even able to solve the medium Tree problem within 10 mins,
which is extremely amazing !!!

 

And I want to share you guys such amazing experience,
so you won't suffer from it.

 

Prerequisite of being a Pro

Before becoming a recursion pro, let's review basics of recursion.

 

Recursion means "calling itself",
and it has 2 vital concepts,
which are Recurrence relation and Base case,

 

  • Recurrence relation :
the relationship between the problem and its direct 
subproblems
Enter fullscreen mode Exit fullscreen mode
  • Base case :
the simplest case, which the function can handle on its own 
without calling itself.
Enter fullscreen mode Exit fullscreen mode

( if you're not familiar with these concepts, you can read the Martin and Dragon story )

 

...to be continued

 

References

Top comments (0)