3

How to explain recursion and iteration to someone without using formulas or single line of code? Difference betwen them, why to use one over another?

(a.k.a : How to explain recursion and iteration to my grandmother)

(a.k.a : How to explain difference between recursion and iteration to my grandmother)

Every one had some kind Tower of Hanoi problem and there they figure out recursion solution and iterative solution. But if you have college (e.g. PM) that dont have idea neither about programing or mathematics how to explain it ?

3 Answers3

5

Today is not the first april, but...

To explain recursion you need to explain recursion.

Jihad
  • 3,284
0

Just use the every day words :)

Iteration You have 15 potatoes to peel :

For each potato, peel that potato.

recursion You need to turn a chocolate plate into chocolate chips:

Split the chocolate pieces in half (and proceed again with the pieces you obtained until each piece is small enough).

Olivier Roche
  • 5,319
  • 9
  • 16
0

Recursion is a method to solve a problem in terms of a smaller problem of the same nature.

To find a word in a dictionary, you open it somewhere, check on which side the word can be and perform a search for the word in that side only. So to find you can... find.

Iteration can be seen as a particular form of recursion where one of the subproblems has unit size. Like flipping the pages one at a time instead of by blocks.