Thursday, 27 March 2014
week 7
I find it interesting that tree and lists and recursion can all be combined to create linked lists. Do nodes the hold data, if they contain cargo? Can there be more then one thing of data in a node? Why is the empty list represented by None, why does there have to be something in the linked list, is it because it has a certain structure, where certain elements have to go? For the second part in a linked list of "a node that contains a cargo object and a reference to a linked list", does that mean the cargo object is referring to the list ? or that the node takes on this recursive structure and acts like a linked list? Are nodes and cargo the same thing, because "the string representation of a node is just the string representation of the cargo" and nodes contain cargo data? I find it interesting that the lists can be looked at by themselves and as a unique list with its own memory address, then they can also be intertwined with other lists to create a bigger list and structure. I also find it interesting that this linked list structure has similar properties of a tree structure. I tried the code on the reading for week 7, to make sure I get the grasp of it (while looking back at the reading to understand what i'm doing). I now realize that the point of None is to show where the list ends and that every Node needs None set for self.next, because of the case where it actually is the end of the list. For list collection, I don't understand how the computer would know what the first node refers to and why you only need to put it in as a parameter to print_list. Is it because it is linked via self.next, to the other nodes? Yet, it says that "there is no variables that refers to the other nodes. We have to use the next value from each node to get to the next node". How do you specifically use next value from each node and where do you use it in the function? For the function "print_list" and "print_backward" I don't understand why they say they can't have a method? I don't understand how you can't use None in a method? What's the real difference then between a function and a method? I learned that you can use wrappers and helpers to divide up operations of what you want a method to do.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment