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)