/
14.12.2018 at 03:09 pm
Cuttings

Recursion, Succinctly Put

The rules of recursion.

... There are 3 rules for recursion:

  1. A recursive algorithm must have a base case.

  2. A recursive algorithm must change its state and move toward the base case.

  3. A recursive algorithm must call itself, recursively.

A base case just means that it has an end point, something to stop it looping infinitely, such as when a particular variable reaches zero.

Changing its state means that through each iteration it gets closer to this variable.

Calling itself just means that you call the function that you're currently in with this new data to pass in.

- Reddit
Reference

Filed under:
#
Words: 103 words approx.
Time to read: 0.41 mins (at 250 wpm)
Keywords:
, , , , , , , , ,

Other suggested posts

  1. 21.07.2021 at 07:46 am / Basis for Base64
  2. 12.02.2021 at 12:55 am / 46 Simple Python Exercises/#10
  3. 22.08.2020 at 05:49 pm / Decoding Code Specimens
  4. 11.01.2019 at 06:39 pm / Clarity of Liskov
  5. 04.01.2018 at 12:00 am / Java Almost Requires An IDE
  6. 15.12.2017 at 12:00 am / The Python Paradox
  7. 03.07.2013 at 12:00 am / Craft Versus Discipline
  8. 26.03.2012 at 12:00 am / Apricot Orange Sunsets
  9. 16.03.2012 at 12:00 am / Sentient Vocal Directives
© Wan Zafran. See disclaimer.