/
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. 18.10.2022 at 09:36 am / The Airplane Test of Fluency
  2. 11.06.2022 at 07:24 am / Vampiric Pathology
  3. 30.04.2022 at 10:36 am / Masters of A Fraction of A Dot
  4. 07.04.2021 at 12:00 am / Harangued Commitments
  5. 03.12.2017 at 12:00 am / Declarative, Imperative, Functional Sandwiches
  6. 23.07.2015 at 12:00 am / The Line Between Gifts and Bribes
  7. 18.07.2014 at 12:00 am / Keep Learning Songs
  8. 17.03.2012 at 12:00 am / Upper and Lower Hengsha
  9. 15.03.2012 at 12:00 am / Cel-Shaded Arena
© Wan Zafran. See disclaimer.