Continuing on since my last post on Big O, which involves time and space complexity of programs, I'm adding a quick recall of an often used, if not completely understood concept. RECURSION!
What it do?
Recursion, in the most basic terms ,is a function that has the ability to call itself.It is used all the time in in programming and is seen as a cleaner alternative to iteration.
With recursion, you use a different input each time until you reach your base case.
For example, you have an array of numbers and you want to find out which of the elements are odd. So knowing that even numbers are anything divisible by two with no remainder, I can say my base case is
N%2 where N is an element in the array divided by two with no remainder.
I could put this in a helper function that uses this as the base case when no matter what my inputs. We need a base case and different inputs to ensure that program returns the base case when conditions are met.
So this was my quick recall of recursion. I will come back and post an updated version as I learn more. Constructive criticism is greatly appreciated and hopefully this helps you too.
Thanks for reading.....k bye :)