/
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. 29.03.2023 at 10:57 am / Moving Away from Todoist - to Taskwarrior, SSH & Dropbox - Part 2
  2. 11.06.2022 at 09:09 pm / 大蛇に嫁いだ娘 - The Girl Married to the Giant Serpent
  3. 07.04.2021 at 12:00 am / Harangued Commitments
  4. 15.12.2017 at 12:00 am / The Python Paradox
  5. 28.09.2015 at 12:00 am / Mocking the Law - Excessive Judicial Discretion
  6. 10.12.2013 at 12:00 am / Yellow Rails
  7. 22.04.2012 at 12:00 am / Ludicrous Ace
  8. 21.04.2012 at 12:00 am / Cinematic Mass Effect
  9. 01.04.2012 at 12:00 am / Skipping Galaxies Over Coffee
© Wan Zafran. See disclaimer.