/
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. 04.07.2024 at 08:43 am / Chronic Key Switching
  2. 29.03.2023 at 09:38 am / Moving Away from Todoist - to Taskwarrior, SSH & Dropbox - Part 1
  3. 10.06.2022 at 07:44 pm / Teach Thy Tongue to Say: 'I Do Not Know'
  4. 10.07.2021 at 01:46 pm / Plants Are Maths
  5. 27.06.2021 at 12:49 pm / Eloquent Javascript / Chapter 2, Exercise 03
  6. 23.06.2019 at 10:59 am / Mood-Clustered Compositions
  7. 19.08.2018 at 11:13 pm / The Brain-Attic
  8. 04.01.2018 at 12:00 am / Java Almost Requires An IDE
  9. 03.12.2017 at 12:00 am / Declarative, Imperative, Functional Sandwiches
  10. 25.09.2010 at 12:00 am / 汗牛充棟
© Wan Zafran. See disclaimer.