In: Computer Science
In 1-3 sentences, describe how you would "Find a path from lab to Del Taco using only sidewalks on an island", Recursively using C++
Recursive function is a function that calls itself recursively. Loop restarts and pop up the old data that was previously stored.It is like doing same process in the same place. But recursion hold all the data from start till the current instance and moves on. It is like doing same process but from resultant place of the previous iteration.
To find a path from lab to Del Taco without using google maps and using only sidewalks on a island:
step 1: Ask the way to Del Taco to a stranger nearby.
step 2: Remember the direction, the stranger told you.
step 3: Walk on the same direction, the stranger told you along sidewalk .
step 4: If you feel lost or can not find Del Taco go to step 1.
Here, step 4 calls step 1 which is the same process but everytime when you reach step 1, It will not be the same place anymore and you will be more closer to Del Taco. As every iteration continues from it's old resultant, this situation is recursive like a recursive function in c++.