Sunday, 2 March 2014

Week 7: Recursion

After dealing with recursion for most of the term  and implementing it in our first assignment I've come to appreciate the usefulness of recursion in solving certain problems and how well it simplifies other problems that can be solves without recursion. The basic concept of recursion is that it takes a problem such as counting the depth of a tree, establishes a base case (a tree with one root and two nodes) to be run when the function is executed and if the nodes also have nodes (the depth of the tree is longer than 2) then the function is run but this time with the nodes as roots in the input of the function. Thus the function continually runs the function over and over again with different input until it reaches the end of the the tree, probably returning an accumulator than was counting each time the function was executed recursively, indicating that another depth level was accessed. Recursion proved to be the most effective way to solve the problem presented to use in assignment 1, figuring out a solution that did not involved recursion proved impossible to me, and now I can look at problems and feel an intuition on whether to use recursion to solve it or not.

Due to me being overloaded with midterms and assignments this week I was not able to attend the lecture or review the lecture slides so I cannot offer any input on what was presented in class unfortunately.

Until next week,
Maxim Isakov

No comments:

Post a Comment