/
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. 01.04.2023 at 11:27 am / Search Notes Fast: With Taskwarrior, jq & ripgrep
  2. 27.06.2021 at 12:49 pm / Eloquent Javascript / Chapter 2, Exercise 03
  3. 14.01.2020 at 01:24 pm / Third Time's A Charm
  4. 14.09.2019 at 12:00 am / Narratives Hold
  5. 16.10.2015 at 12:00 am / Statements Without Data
  6. 28.09.2015 at 12:00 am / Mocking the Law - Excessive Judicial Discretion
  7. 18.06.2015 at 12:00 am / Crisp Tweets
  8. 13.06.2015 at 12:00 am / Sexism Against Modern Men
  9. 17.12.2014 at 12:00 am / 午・午年
  10. 14.08.2010 at 12:00 am / 豹変
© Wan Zafran. See disclaimer.