Sunday, 9 February 2014

RECURSIONS

The last lab and also the past few weeks were all about getting to know how recursion works. Recursion is a way of calling a particular function continuously in itself. It works for situations where you need to keep checking the same thing or the same conditions over and over again.

For example if you need to go through every element in a nested list or search list. It is basically a way to avoid repetition of code and so you just call the function in itself. This recursion method was useful in assignment one where we needed to call the move functions repeatedly.

 In the previous lab, we had to create a function that finds a particular number in a search list. This meant we had to check different conditions for each list in the search list and recursion was a very useful method to use. We were also taught how to use recursion in relation to binary numbers. I actually never thought it could be possible to call a function within itself. It took be quite a while and a lot of tracing to fully grab the concept.

No comments:

Post a Comment