Wednesday, 30 March 2016

week 11 -- reflecting on recursion



Only one more week to go after this and then it’s officially exam season. It’s been a good semester for my advance in the field of Computer Science and the mastery of the Python language. If there’s one important concept where I can see progress having been made, it has to be on recursion.

At first, recursion simply seemed nonsensical. A function calling itself and then practically starting over from the beginning of the code? That just didn’t make any sense. However, after lots of practice in class, labs and parts of Assignment 2, it really isn’t as hard as it once seemed. Tracing was especially helpful to get to this point, without being able to trace a recursive function, one simply cannot know what the recursion does every time, it is critical to understand what’s happening. Now, I am able to write a recursive function or method given a docstring, figuring out what special cases need to be considered (if any), and what the general case is where recursion is to be called. By understanding recursion, it also allowed me to understand and implement functions and methods on Trees and Binary Trees, both important data structures. It really simplifies the alternative of having to write loops in order to find the depth, height, leafs, or any other properties of Trees (be it the general Tree or a Binary Tree). Of course, there’s more to recursion than just the general structure which was often worked on in lectures; notably in Assignment 2, recursion was extremely helpful for depth-first search, a tedious task yet it would seem more complicated to write the same working code through various loops and conditions within it.

All in all, I’ve become much more proficient writing code and using different techniques on different types of data structures – stacks, Trees, queues, Linked Lists – but like discussed above one significant tool is the ability to use recursion – potentially on these same data structures – and understand its implementation through tracing.

No comments:

Post a Comment