/
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. 07.04.2021 at 12:00 am / Harangued Commitments
  2. 25.08.2020 at 09:03 pm / Hamstrung Limitations
  3. 10.01.2020 at 10:40 am / Learned Lumber
  4. 23.06.2019 at 10:59 am / Mood-Clustered Compositions
  5. 11.07.2016 at 12:00 am / SublimeREPL's Slow Printing/Freezing - A Solution
  6. 18.06.2015 at 12:00 am / Crisp Tweets
  7. 14.06.2015 at 12:00 am / Just the Two of Us (6-Bar Guitar/Sax Copy)
  8. 03.01.2014 at 12:00 am / Write With Vigour
  9. 04.07.2012 at 12:00 am / When To Not Use Data Structures/Algorithms
  10. 19.03.2012 at 12:00 am / Lush Exoplanets
© Wan Zafran. See disclaimer.