Thursday, 12 March 2015

Week 8

My gut reactions to the linked list concept was one of relief to be sure. Working with trees beforehand, I found, was much harder than working with linked lists due to its branching structure. It was a nice change of pace from using recursive methods/ functions back to some loops. In my opinion the linked list structure is pretty straight forward, literally. the node points holds two pieces of information, the data and the pointer to the next node in the list. Fortunately I did have prior programming knowledge in linked lists in Java, I find linked lists, as with most structures, much easier to visualize and code in python, probably because visually the python language is more simplistic.

Initially, I did have small problems in programming the different functions in the linked list code because the percentage of making a simple error is rather large. When I was trying the lab most of the problems arose when I would begin to lose track of LLnodes because traversing the list with variables such as curr_node, prev etc, in a while loop, if not careful, could lead to infinite loops or lead to node pointers trying to point to a node after None which would lead to errors. I found that the advice of drawing a pictures to better refine an algorithm was best in minimizing such mistakes. To my relief, no major questions were created just a matter of refining my thinking towards linked list structures. Just in time for the midterm too.

1 comment:

  1. Hi Adam,

    I completely agree with the points you made. It's very easy to trip up when walking through a linked list and mistakenly assigning things that point to the wrong Node. I also noted too that for linked lists, you have to take into account special cases such as at the beginning and the end node. For example, if you had to add a node to the front, then the 'nxt' attribute would be the rest of the linked list and the front would refer to the new node. Overall, I think it is helpful to draw these things out on paper to gain maximum clarity.

    ReplyDelete