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

Heroku

This site is built on Heroku

Join the ranks of developers at Salesforce, Airbase, DEV, and more who deploy their mission critical applications on Heroku. Sign up today and launch your first app!

Get Started

Top comments (0)

Qodo Takeover

Introducing Qodo Gen 1.0: Transform Your Workflow with Agentic AI

Rather than just generating snippets, our agents understand your entire project context, can make decisions, use tools, and carry out tasks autonomously.

Read full post

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay