Wednesday, April 8, 2015

Week 12: Last Impressions

Walking into 148, I had similar expectations as I did with 108 in terms of being an introductory course. Reflecting back, I do stand by my original post. As more of a tourist to computer science and programming with little prior background, I think the greatest challenge in the course was not any exact conceptual hurdle per se, like recursion, efficiency in sorting, or even tippy, all of which I really quite enjoyed tackling, but it was the teaching method and expectation to learn and explore on a more independent level that I had anticipated. This was probably made a little worse with the strike. And I don't mean to sound like my experience was soured in any way. I do appreciate the work that the instructors put in to keep the course running and doing the best they could under the circumstances. I really enjoyed the challenges in the assignments, the weekly labs, and even writing this slog however inconsistent it was. I think I'll continue to pursue computer programming as a hobby more so than beyond any serious academic capacity. To my partners any else looking to push forward in computer science, I wish you the best of luck on the final and a great summer ahead! Farewell!

Tuesday, April 7, 2015

Week 11: Revisiting the Past

This is our final week and I'd like to shift back a bit first to comment on Week 6-9, as I didn't much of an opportunity before. I would also like to revisit some of my earlier thoughts of the course and the material itself.

During reading week, I did have a chance to look over a few slogs, and came across one particular slog that stood out from the rest. Having no graded work, labs or any feedback for a solid month, and being an evening student, which naturally means little access to the office hours, this slog really was a helpful resource, not just for having something to compare my own labwork against, but also having a different insight and perspective of the topics covered on a weekly basis. And helpful, might I add, is an understatement. I owe a special thank you to you, AntiAromatic, whoever you are. Drinks are on me, if we ever meet.

Week 6 - Object Oriented Programming

Looking back at Object Oriented Programming (OOP), before we had been introduced to the concept, much of the code we had written was largely a disorganized series of functions, and truthfully, I had little idea of the concept of breaking down functions into methods contained within objects, which could all function in unison as modules. This became clearer throughout the assignments, in the way in which the starter code was provided to us. It made sense to have an overarching class for game strategy that would inherit the attributes of a random or minimax strategy class if called upon. It made perfect sense to have a master game view module that would call upon game state, which would then call upon tippy's or subtract square's own state when whichever was in play. I think my underline impression of OOP is that it adds organization, structure and flexibility in modularity to code writing. If you for instance, wished to add a difficulty level in a game design, you could do so without affecting certain existing classes of difficulty levels.

Week 7/8 - Recursion & General thoughts

Throughout Week 7 and 8, our focus was on binary tree structures and linked lists. Finally, something more digestable, but still with some aspects of recursion here and there - a topic I found most challenging and admittedly dreaded... yet strangely fascinated with.

For the most part, working with nested list structures earlier in the term was understandable. Essentially, in a recursive function there's the base case and general case that follows this format:

def recursive_function:
    if # a condition to detect the base case:
        (do something without recursion)
    else #if the general case is encountered:
        (do something that involves the recursive function

Once we moved to binary trees, the order in which the general case and recursive calls also started to matter, further adding to yet another layer of complexity, may be that's not the right word. As an example, if you were to look at preorder visit below:

def preorder_visit(root, perform):
    ''' (BTNode, function) -> NoneType
    Visit each node of BT rooted at root in preorder  and perform.
    >>> b = BTNode(8)  
    >>> b = insert(b, 4)  
    >>> b = insert(b, 2)  
    >>> b = insert(b, 6)
    >>> b = insert(b, 12)  
    >>> b = insert(b, 14)  
    >>> b = insert(b, 10)
    >>> def f(node): print(node.data)
    >>> preorder_visit(b, f)
    8
    4
    2
    6
    12
    10  
    14
    '''
    if root is None:
        pass
    else:
        perform(root)
        preorder_visit(root.left, perform)
        preorder_visit(root.right, perform)

but instead, if you had reversed everything following the else statement to:
        preorder_visit(root.left, perform)
        preorder_visit(root.right, perform)
        perform(root)

You could easily and inadvertantly end up with a postorder visit function.


Week 9 - TT#2

This was the week we had our second midterm. I was pretty ashamed of myself for missing the arity question. Literally a throwaway. I had always assumed that arity meant the maximum branching factor at some node in a tree structure. A tree of height 3 and arity 3 with the greatest number of nodes would look like this. This I get, or got rather.


             O
            /|\
        O O O                       (I really should have done this on paint)
       /|\  /|\  /|\
   OOOOOOOOO

Now what about the same tree of height 3 and an arity up to 3 with the least number of nodes?

            O                         O
           /                              \
          O              &             O
         /|\                                 \
        O O O                            O


This I didn't. Can you guess which one I wrote? :/


Week 11 

At long last, we arrive at week 11. The Strike ended on Friday, March 27th with a vote to settle through binding arbitration. I can't decide if I'm actually relieved or mildly disappointed that it's dragged out for so long and the weight of our course work has changed. Again. This week's topic asked us to revisit an earlier slog to see whether we agreed or disagreed with an earlier slog. Looking back at Week 10 and having finished assignment 3 (with 30 mins to spare before the deadline :P), I can say with certainty that I was glad I went with option B, and had the opportunity to work with recursive tree structures in greater depth. And from the looks of it on piazza, I think it's safe to say a lot of other students felt the same way. Although... I can't help but feel as though I may have missed out on something else that could have been... and gone with option A to improve my understanding of efficiency, memoization and pruning. Maybe something to return to in the summer.

Nah, I doubt it.




Monday, March 23, 2015

Week 10

It's week 10, and it looks like the strike is still ongoing. The latest offer was rejected only by a thin margin. Hopefully things will resolve soon and well for all parties. It is starting to become more difficult with each passing week without the support of our TAs and the feedback from the labs. And yes, I'm writing about week 10, as opposed to my impressions of W9. This is what I get for being inconsistent and easily confused.

On a different note, our final assignment was posted this week with the option to either A) revisit minimax strategy, optimizing its efficiency through the processes of pruning, myopia, and memoization -- not to be confused with memorization or B) investigate the space of game sequences, particularly examining the size of the game states and redundancy, i.e. what percentage of the game states are considered repeats.

I will likely steer towards option B, given that it seems a bit more manageable and second, traversing through trees is something we have yet to fully tackle in depth. Our last submission of assignment 2's minimax strategy was a headache I'd like to avoid. This of course is not to say, I wouldn't want to better my understanding of minimax. ¬_¬

Tuesday, February 17, 2015

Week 5: Object Oriented Programming

Building upon our understanding of object oriented programming and revisiting some previously covered concepts, week 5's material took a closer look at the implementation of classes and methods, particularly in the context of recursion in the tree structure - tree.py. Here, we first defined a number of functions including __contains__, leaf_count, and decendents_from_list, and eventually promoting each function to a method of the class object Tree.

I feel a couple of new items worthy of highlighting include:

a) copy(), a built-in function of python
b) the syntax and use of if and else in the examples of init and repr:

     def __init__(self, value=None, children=None):
self.value = value
self.children = children.copy() if children else []

&

    def __repr__(self):
        return ('Tree({}, {})'.format(repr(self.value), repr(self.children))
            if self.children
            else 'Tree({})'.format(repr(self.value)))

Classically, we were taught that if and else should begin at the start of a statement, otherwise we would usually return some form of a syntax error. Here we see the exact opposite, and it works! It seems as though we're breaking more and more of these once arbitrarily defined rules. May be they were constructed as a way to help us understand the basics without having the confusion... Is it just me, or is python starting to feel more obscured?

I'm also beginning to appreciate the complexity of using an array of functions within functions or methods, rather. I shamefully admit that this took me way too much time to understand.


def descendents_from_list(t, L, arity):

    q = Queue()
    q.enqueue(t)
    L = L.copy()
    while not q.is_empty(): # unlikely to happen
        new_t = q.dequeue()
        for i in range(0,arity):
            if len(L) == 0:
                return t # our work here is done
            else:
                new_t_child = Tree(L.pop(0))
                new_t.children.append(new_t_child)
                q.enqueue(new_t_child)
    return t


As an aside and a final note, assignment 2 was posted recently and for those trying to get a better grasp of minimax, I found a good resource to read up on: http://neverstopbuilding.com/minimax. Cheers.


Monday, February 9, 2015

Week 4: Recursion

Last week's material (or two weeks ago, rather) examined some of the basic concepts of recursion, focusing on tracing through various elements and nested lists. I was intrigued by the concept of a function able to call upon itself repeatedly through any level of complexity, and admittedly, skeptical when we were first presented the example sum_list in lecture.

While we have yet had the opportunity to write recursive code in depth ourselves, the tracing exercises in lab have been greatly helpful in better understanding the principles behind recursion, the use of base cases and the way in which it influences the overall output and function. I am still having some difficulty implementing recursive code, but hope to have this down with a bit more practice in the coming weeks.

Monday, February 2, 2015

First Few Weeks of CSC148

Four weeks in and I am definitely still trying make sense of some of the course material, hopefully in time for our first midterm this coming Wednesday. Before taking CSC108 in the fall, I had little next to no computer programming experience. While I am enjoying CSC148 so far, it is a different format than what I have been accustomed to. I feel as though there is a bit of a leap between the two courses. Either that, or there is undoubtedly a gap in my knowledge base. Maybe it's both.

Week one, we jumped right into object oriented design, barely glossing over any of the fundamentals. I guess that part was assumed, not that I'm complaining, of course. Week two and three, I'm starting to get a better idea of class implementation and inheritance. I'm also starting to understand the importance of starting labs ahead, and using my time effectively for questions and feedback. Something I feel is just a tad lacking.

Perhaps I'm the only one, but I miss the detailed explanations and exercises we were able to slowly walk through in each week's lesson in 108. I miss PCRS, the videos, and the the instant gratification of knowing whether my code passed or failed. Above all else, I miss the structure. Although, I appreciate having the lab setting is extremely helpful in meeting other classmates, and certainly provides an invaluable opportunity to interact with the TAs face to face with questions, it just hasn't been quite the same. I guess what I'd like to express is that CSC148 is different. It's different in that it requires a higher level of independent learning and initiative to get the feedback you (read: I) need.




Thursday, January 22, 2015

"Why Geeks should write?"

Whether it's in the field of computer science or any discipline, writing serves as an important way for us share experiences, impart knowledge to others, and communicate ideas - ideas that may often be complex or convoluted which may not be readily translatable without some intermediary language (one that is non-programming).

Over time, the collection of these experiences and ideas shared through writing, can provide a way in which we can refer back and learn from mistakes and challenges faced personally or by others. The blog examples in Week 3's readings illustrate the importance of writing. We can see how maintaining a journal in debugging, for instance, can help prevent us from repeating errors from the past. Though, if we do indeed repeat such errors, we have a way of methodically referencing and correcting them. We also see in Joel Spolsky's blog how other computer scientists, through writing, can provide invaluable advice and insight to those new to the field.