Send Close Add comments: (status displays here)
Got it!  This site uses cookies. You consent to this by clicking on "Got it!" or by continuing to use this website.nbsp; Note: This appears on each machine/browser from which this site is accessed.
Recursion introduction


1. Recursion introduction

2. Divide and conquer
Tails-tailsA divide and conquer problem solving method is a top-down method that breaks a problem into smaller parts, solves each smaller part, and combines the solution (in a bottom-up manner) to solve the original problem.

3. Decomposition

4. Decomposition
Decomposition is breaking something down into smaller parts.

Examples:

5. Composition
Composition is putting parts together to form larger entities.

Examples:
   if f(x) = 2*x,    and g(y) = 3*y,    then f(g(z)) = 2*(3*z) = 6*z


6. Recursion

7. Recursion
A recursive definition is a definition that is defined in terms of itself.

The mathematical term "reflexive" is used to define something in terms of itself.

That is, the value x, whatever x is, is equal to itself (in a reflexive relation sense).

8. Recursion
In more technical terms, a binary relation R over a set X is reflexive if every element of set X is related using the relation R to itself (in a true manner).

This definition becomes important in later courses such as algorithms and data structures.

9. Gender is reflexive
Consider the relation "is the same sex/gender as".

Although there have been issues in the news about what "gender" really is, one should find agreement that whatever the gender is of a person, that that person has the same gender as that person. That is, it is a reflexive property.

10. Recursion
Have you ever heard someone say "do as I say, not as I do"? That is, the rule applies to others and not to oneself. That is, the rule is not reflexive.

11. Email
Have you ever sent a email message to yourself?

Did you then receive an email message from yourself?

That is, you were sending email reflexively.

12. Ouroboros
OuroborasA common saying/symbol for self-reference is the snake eating it's tail.

The ancient symbol of Ouroboros, via the Greek ουροβόρος for "tail" and "food", originated in Egyptian symbology.

Cats often can be tempted into chasing and trying to bite their own tail.

13. Envelopes
Have you ever sent a self-addressed envelope?

Now how is an envelope supposed to address itself?

One can self-address ones-self with the words "I" or "me".

14. Importance
Why is recursion so important to computer science?

In all fields, some things give a person a competitive advantage. In each field, you can still succeed, but having certain skills results in a huge advantage compared to someone who does not have that skill.

In computer science, one can work hard and learn how to think and program recursively, but it takes some mental time and effort and practice.

15. Hofstadter's Law
A more elegant statement of a recursive self-referential principle is Hofstadter's Law.

16. Recursive
Something is recursive if it directly or indirectly refers to itself. Problems sometimes result if the recursive relationship is circular.

A procedure or function is recursive if the procedure and/or function calls itself either directly or indirectly.

Remember the message passing model.

17. Recursive definition
A recursive definition is a definition that refers to itself in some way

Dictionary definition:

18. Recursion
The use of recursion provides a powerful design and implementation strategy that is, in essence, a divide and conquer problem solving strategy.

19. GNU
Acronyms can be recursive, such as the acronym GNU (GNU is Not Unix) . (gcc compiler)

An Acronym can describe itself in some way, such as a TLA (Three Letter Acronym) . Note that a TLA is a TLA .

20. Smaller instances
A recursive algorithm or definition is circular, but also, to be well defined, needs to refer to a smaller instance if itself. One example is a set of Russian Matryoshka (матрёшка) dolls.

Recursive definitions are powerful methods to allow a rule or rules to handle smaller instances of themselves.

21. Fractal: Endless coastline
Koch descentFractals are self-similar objects. As one zooms in on a fractal, it can appear endless.

22. Fractal tessellation
Two Koch snowflakes of different orders can be used to tessellate (i.e., fill) the plane.

Koch tesselation
Note: It is possible to use more than two sizes of snowflakes to tessellate the plane.

23. Imperative programs
Recursive rules apply to parts of imperative programs, though it is not as obvious.

Consider the while loop defined in pseudo-code as follows.
   while b do       S       end while


24. While loop
The above while loop can be defined (as in a macro expansion) as follows.
   if b then       S       while b do          S          end while       end if

The expansion can go on until the while loop is complete. This is sometimes call loop unrolling (in, say, code optimization techniques).

25. Self reference
This sentence is false!

The previous sentence refers to itself (while this sentence refers to another sentence).

Note that language (and programming languages) can inherently refer to itself, directly or indirectly.

Such references can be mutually recursive (or circular).

26. Circular arguments
True and FalseA circular argument or circular reasoning never ends, or creates a paradox.

27. Chicken or egg
Chicken and EggWhich came first, the chicken or the egg?

Such paradoxes are central to computability and information theory in computer science and information theory.

28. Recursive
Def: Recursive. Adjective. Something that refers to itself. See Recursive.

Recursive: something that refers to a smaller instance of itself (to insure termination), as opposed to something that is circular (does not terminate).

For a mutually recursive set of functions to terminate, each recursive call must be to a smaller instance (in some sense) of the overall problem.

29. End of page

30. Multiple choice questions for this page

31. Acronyms and/or initialisms for this page