Thursday, 27 February 2014

Recursion Week 7

For the past couple of weeks, Danny has taught us how to use recursion. It has been one of the most useful methods of programming that I have learned so far in this entire course. Recursion can be used in most of my programming code to solve my problems. It's is useful when it comes to Trees, Linked Lists, and re-iterating over certain loops.When given data of nested lists, dictionaries or tuples, recursion allows us to recall the same function to go into the nest of data to grab the information that we need. For example, in week 4 we were given the following code:

def rec_max(L):
    """
    Return the maximum number in L, a possibly nested list of numbers.
    
    >>> rec_max([17, 21, 0])
    21
    >>> rec_max([17, [21, 24], 0])
    24
    """
    return max( # the maximum of
        
        # list of maximums of sublists or plain numbers in L
        [rec_max(x) if isinstance(x, list) else x for x in L])

 This code during the lecture allowed us to the find the maximum element within the list of nested lists. Without recursion, it would be difficult to implement the code for this function. With recursion, by recalling the same function and re-iterating over the list every time an item in the main list is a list, we can append each item within the nested lists to one big list. Once we have the one big list of all the items without the nest lists, we can find the maximum element with ease. 
Furthermore, by utilizing the recursion method combined with list comprehension, I am now able to write code for complicated functions within one line. Without the combination of these two methods, writing code for my functions would be extremely difficult and long to do. In conclusion, by using recursion, I can recall the same function to preform the same function over a series of data to collect the information that I need with ease. Without recursion, coding things like Trees and Linked Lists would be incredibly difficult. 

Thursday, 13 February 2014

Recursive Structures

This week, Danny taught us about nodes and its properties like edges and roots. It's great that Danny was able to give us all the terminology related to the structure. It med it much easier to point out things while tracing through the examples and explain why with my fellow classmates. Danny helped make the lectures easier to follow through the use of picture and drawing out the sequence with pre-order and in-order. Without the picture I would have had a much harder time understanding the material. Other than that, this weeks lecture were very interesting and new to me during this course so far.

Thursday, 6 February 2014

Recursion Cont'd

This week, Danny allowed us to trace some recursive functions. This week gave me some insight in how I should be thinking about recursion and the steps to follow. I thought that this weeks lectures were really helpful as well as the tutorial. The tutorial gave me a better understanding of what recursion does and how I should be coding programs that require recursion. Thanks to my TA, he was able to explain recursion to me in a way that was understandable to me. This weeks tutorial and lecture helped me greatly with our first assignment.

Thursday, 30 January 2014

Week Four, Recursion

This week, we were given a better understanding of what recursion is. The whole concept behind recursion is interesting to me. I especially liked Wednesdays class where by using recursion and turtles, we were able to create a display of many fractals. At first when the tracing the code, I had a little bit of trouble. I wasn't following the recursion method when tracing and it gave me a weird picture. Now that I have seen what it actually is with the display of fractals, it's easier to trace the code and demonstrate what it does. I will probably look over the readings again just so I can get a better understanding of recursion but overall I got the gist of the concept. Recursion will be a handy thing for me when it comes to coding and once I 'master' it as Danny says, then I will feel more confident.

Thursday, 23 January 2014

Object-Oriented Programming

Over the past couple of weeks, I have learned much in CSC148 under the teachings of Danny Heap. The readings are a huge help as well. Considering that I didn't really have any past knowledge of programming before I came to the University of Toronto, I found the readings incredibly useful when I needed to know some background knowledge of programming. Specifically speaking, the readings regarding object-oriented programming in week one and inheritance during week three. I found these readings to be extremely helpful when I didn't understand certain concepts of inheritance and the overall background of programming. I had no idea that object-oriented programming stretched as far back as the 60's. I realized that everything that we do in Python to an extent revolves around object-oriented programming. Classes, instances, and methods are all part of object-oriented programming. We use object-oriented programming to deal with ideas and concepts that apply to the real world. Whether it be a graphing program or even a game, it all deals with objects in order to obtain the desired goal. One of the few questions that I have about object-oriented programming is how complex could our programs become. Considering that in class we have been only working with smaller classes and functions that don`t require a lot of time, what is the extent of complexity in object-oriented programming. I essence, at some point in time during the course I would like to see a very big and complex piece of programming that deals with object-oriented programming, and try and follow the logic and steps behind the code. Even though I am only in first year, I would like to know how complex could things get and how they could evolve in the future.