bravedevelopment avatar

Programming Concepts - Recursive Function - Real Life Example (road-to-home ๐Ÿ˜๏ธ)

bravedevelopment

Published: 13 Mar 2020 โ€บ Updated: 13 Mar 2020Programming Concepts - Recursive Function - Real Life Example (road-to-home ๐Ÿ˜๏ธ)

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

Leave Programming Concepts - Recursive Function - Real Life Example (road-to-home ๐Ÿ˜๏ธ) to:

Written by

Read more #adventure posts


Best Posts From bravedevelopment

We have not curated any of bravedevelopment's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.

More Posts From bravedevelopment