Sunday, March 9, 2014

Week #8

I got my term test paper back this week, it was not bad. When I checked the paper, I saw some stupid mistakes that lowing my mark, this is again teaching me how important it is to double check the codes.

This week we learned another type of recursive data structure -- linked lists, which is either an empty list or a node with value and a reference to a linked list. For example,L is a linked list, L is empty list if L. value = None,L.rest = None. To add a node in front of L, we use the method: prepend. I was very confused about this method, I wasn't sure how it worked until I finished the lab 8. Now, I know that when we call L.prepend(7), then L. value = 7 and L.rest = copy(L), here the only node created is L.rest and assign it to copy of L, then change the value of front node to 7.

To get a really clear idea of how the linked list works, drawing  pictures before and after an operation will be helpful. At least I got a lot of benefits by doing that.

No comments:

Post a Comment