Saturday, February 15, 2014

Week 6 -- February 15th

After a hectic week of scrambling to finish A1 and studying for a CSC165 midterm, Danny left us pondering the tree data structure. The writer at http://gr148slog.blogspot.ca/ described it really well -- in a way that I didn't think about, but I think it will help me in long run. He describes the roots and children as the way we drew them when we were young. We started with a base tree, and drew two branches leading out of each leaf part.

I must confess, I did not finish A1. I completed all the steps, but I just could not figure out the 4-stool move algorithm. I knew that finding "i" would be a lot harder than just integer-dividing it by 2, but I did not even understand the recursive part of it. In the end, I had a function using the 3-stool cheese function Danny wrote in class that moved the cheeses in fewer moves than the Hanoi method, but more moves than the best-known TOAH method. I realize that assignments require students to just sit and THINK. I would not say that I spent enough time thinking about the assignment in general. It was pretty interesting how everything came together, and I think it showed me how useful object-oriented programming can be on a grand scale.

All in all, I think I did pretty well for having worked alone. Note to self: look for a partner sooner.

Who actually puts cheese on stools? I couldn't even find an image of one.

Saturday, February 8, 2014

Week 5 - Feb 8th: Midnight Blogging -- Recursion

The week before an assignment is always crazy. I never seem to learn my lesson. This was the first assignment for Computer Science that I have attempted without a partner, and I realize just how much "two heads are better than one" holds true.
Recursion is something we must understand at this point. It's a shame I still don't understand it. I thought I did, because seeing Danny do it in class made it seem easy. We also did it in lab, where I got a better understanding of it but I still fail to wrap my head around it all.
What I do understand is that there must be a base case -- a base case is a conditional statement that will stop a recursive function from running and causing errors.Otherwise, the function will run, calling itself within itself, and return something each time so that the function can be called again, using the returned item as a parameter. This goes until the base case is fulfilled.
What I do not understand is how a function calls itself. To me, recursive functions look like undefined variables, where they are referenced before they are defined. Perhaps I should trace functions in my free time, especially since there is an important recursive function to be written at the end of A1.