r/learnprogramming • • Apr 05 '22

Name one programming/comp sci concept you never understood and if you understand it, try to explain it to them

Name a programming concept such as virtual functions, pointers, certain algorithms, etc that you always had a hard time understanding and why.

Someone else who reads yours and does understand it, try to explain it to them to help them learn

1.6k Upvotes

738 comments sorted by

View all comments

105

u/NewInHere__ Apr 05 '22

recursion, just... recursion

12

u/MyHomeworkAteMyDog Apr 05 '22 edited Apr 06 '22

Just to add, here are the elements of a recursive algorithm:

  1. A base case, when the algorithm returns an answer without further recursion.

  2. A recursive call, to a smaller subproblem closer to the base case.

  3. A way to accumulate the recursive solutions