Wednesday, 3 February 2016

Week 4

Well, week 4 is starting to pick up. This week we've focused mainly on stacks and lists. I thought stacks were a pretty neat idea, though I admit at first I found them superfluous. I didn't really understand how they differed from or improved upon what lists could already do in Python, but professor Heap's example about balancing parentheses made a lot of sense. Before he explained it I imagined I would take care of the problem using lists. I figured I would add each parenthesis, bracket or brace to a list one after another, and then when I encountered a closing symbol I would just compare it with the most recent addition to the list, and then the next one with the second most recent addition, etc.. But I can see how that solution could get quite complicated, especially when parentheses are being opened and closed inside of another set of parentheses. The stack solution really simplified the problem a lot. I now see the immense value of stacks, though I am having a little trouble imagining what else they could be used for. Oh and we also learned about creating a list whose components are scattered throughout the memory, which I thought was a really cool idea, though I am not sure how Python would implement such a thing. Wouldn't these just be tiny lists? Wouldn't Python still try to get hold of a bunch of adjacent memory slots? I guess I will find out.

No comments:

Post a Comment