Thursday 28 November 2013

Namespaces and memoizing

This week, we learnt about the namespaces, and the scope of variables. We learnt that a local variable cannot be accessed outside the function definition, while a global variable can be accessed only in the global space. The non local variables can be used outside the function definitions. Other thing we learnt is methods, and that methods of subclass override those of the superclass. Another interesting thing was tracing, where we saw the flow of the control in a recursive function, with the help of a visualizer. We saw how functions were called during each recursion cycle, and how values were returned, leading to the final answer. According to me,the most useful thing thing we saw in the last lecture was code efficiency. We used memoizing technique, where we stored previously calculated values in a table, to reduce identical calls to functions to calculate them. We used it on the fibonacci series and saw the results that we could calculate fib(400) using this technique, as compared to fib(40) without it. This concept was then applied to automate functions.

No comments:

Post a Comment