In the first
four weeks of CSC148 we have learnt about classes, subclasses (inheritance) and
recursion. Although it was very valuable to learn about classes and how to make
other classes inherit all of the methods and attributes of another class, in my
opinion the most interesting instrument that we have learnt in the first weeks
is recursion. At first recursion is a very abstract thing to think about, a
function calling its self in its own definition.
When you eventually wrap your
head around what is happening you will realise that it is basically the same as
a conditional loop but a lot cleaner and simpler to implement. Recursion allows
you to use a function that would normally only work with a finite number of instances and allows it to be
used for an (almost) infinite number of instances. As such recursion makes
creating algorithms based on repeating tasks (such as sorting) much easier to
implement.
No comments:
Post a Comment