Sunday, February 9, 2014

Recursions and Namespaces

     This weeks focus has been on tracing recursions and namespaces. The lab was mainly on recursions, and we traced several different examples. It wasn't too difficult to trace, if you picture each call of the function as a branch and the output as the leaves. The more calls, the more branches that grow, the more leaves. We also look at namespaces and the scope in which a names and variables exists. I think the corresponding names sort of sums them up. Global, non-local and local, all give an idea of where the variable will exist. I found this useful in one case in assignment 1. Where I wanted something to be done only once, in a recursive function. So I created a global Boolean variable which I used for a condition, then changed it afterwards. Since, it was not in the scope of the function, it wouldn't not be changed back and forth from True to False, but rather start as True outside of the function, and only change to False within the function. At least that's how I view it.

No comments:

Post a Comment