Programming Concepts - Recursive Function - Real Life Example (road-to-home 🏘️)

What is a recursive function, what does Recursion mean in Programming?
🔹 Recursive functions are functions that call themselves continuously, not in infinity, but until reaching some specified condition.
🔹Recursion is tactic, a concept in development that includes a function or method that calls itself in a recursive way.

Recursive functions can be interpreted sometimes as routines that call themselves in two ways: direct way or indirect way

What is recursion explained by example?

  • It is a powerful programming technique which used to solve one or more practical problems and especially situations by choosing a simple way to break the problem into smaller pieces.
    One Great example would be
"road-to-home" operation
The recursion solution for this operation would be:

-- Origin: You have your starting point
-- Destination: You are at home, you just arrived

The process of going from your origin to your destination Home, it includes the process of recursion. So it would break it this scenario only:

-- 000111 If you are at Home stop walking, recursion over your reached Home
-- 111000 Otherwise, walk a step closer to the home

The road from origin to home is divided in small pieces: steps, and the road is a recursion itself, you walk step by step (repetitive ) until a condition is met. In our scenario, reach to Home.

anthonyreungeres6xt1mwF_iUunsplash.jpg

Photo by Anthony Reungère on Unsplash

Generally a recursive function, method, algorithm has the logic as following:
=> if a condition deriving from a method you have set solves the problem, then stop the recursion, otherwise simplify the problem more recursively by dividing it in small pieces till to the resolving point.


It's amazing how real-life examples can be used to explain algorithmic and programming concepts. Love what's you do. Kudos Stemians

Sort:  

Excellent work

But the end of all things has drawn near. Therefore be sober-minded and be sober unto prayers.(1 Peter 4:7)

Question from the Bible, Who can lead me to heaven?

Watch the Video below to know the Answer...
(Sorry for sending this comment. We are not looking for our self profit, our intentions is to preach the words of God in any means possible.)


Comment what you understand of our Youtube Video to receive our full votes. We have 30,000 #SteemPower. It's our little way to Thank you, our beloved friend.
Check our Discord Chat
Join our Official Community: https://steemit.com/created/hive-182074

Coin Marketplace

STEEM 0.21
TRX 0.20
JST 0.034
BTC 99049.34
ETH 3373.17
USDT 1.00
SBD 3.08