/
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
Source: Reddit - Reference
Filed under:
#
Words: 7 words approx.
Time to read: 0.03 mins (at 250 wpm)
Keywords:
,

Other suggested posts

  1. 17.02.2025 at 09:13 am / Shakespearean Apples Are Not To Be
  2. 16.12.2024 at 02:42 pm / Vim As A Language
  3. 23.03.2023 at 11:12 am / Copywork vs Master Studies
  4. 11.02.2021 at 12:56 am / 46 Simple Python Exercises/#01
  5. 22.08.2020 at 05:49 pm / Decoding Code Specimens
  6. 11.07.2016 at 12:00 am / SublimeREPL's Slow Printing/Freezing - A Solution
  7. 28.09.2015 at 12:00 am / Mocking the Law - Excessive Judicial Discretion
  8. 20.06.2015 at 12:00 am / Mike Tyson on (His) Lawyers
  9. 29.11.2013 at 12:00 am / ガラケー Garakei Evolution
  10. 20.04.2012 at 12:00 am / A Misty Morgue's Bat
© Wan Zafran. See disclaimer.