Saturday, 22 March 2014

Week 8

This week, I will be talking about "linked lists". I used to hate linked lists (and recursion in general), but now I finally realize how useful they can actually be.

Linked lists basically work on the principle, that you have an element, and that element is connected in a fashion to the other parts of the list, which in terms is connected (linked) to other parts of the list. Essentially, what we are doing is making a recursive definition for a linked list.

The true purpose of a linked list comes in to play, when we consider how a programmer would add and remove elements from a list. The way in which this happens with a traditional list is through shifting all the elements and then inserting the element that we require at the place in the list that we require. When we do this with a linked list however, we see that we don't have to worry about the references to the rest of the list, and we can simply only focus on the parts of the list that we are inserting/deleting items from.

I had some practise this week with linked lists- in particular, with how a linked list can be used to adapt to various functions. I did have difficulty with the lab #6, that focused on this particular topic, however by using the TA's suggestions of writing out the linked lists using diagrams and pictures, and thinking of the topic in a recursive fashion, I was a master at this in no time at all.

I would like to make a comment on one other blog this week- from http://adauoftcsc148.blogspot.ca/. He talked about the manner in which we view a linked list as a "head" and a "tail", which is another way to visualize these types of lists. I enjoyed learning about this representation since it seems very intuitive to me, how to create a linked list, by just worrying about this two parts,and how they are connected through our coding of the recursive linked nodes in the list.

No comments:

Post a Comment