Saturday, 14 March 2015

Linked Lists

     Hello there once again Sloggers! Can't believe we're already more than half way done this Winter semester, let alone 1st year! Almost there guys, the final push!

       So Week 9 talks about Linked Lists! To be honest, this concept was some what confusing to me at first and watching this video really helped me grasp the concept.

So basically the most typical structure of Linked Lists code goes somewhat like:

cur_node = self.front  #This is to set a variable to the first node in the list        while <some condition here>: #Depends on the problem

   cur_node = cur_node.nxt #Update the node to the next one

I think of it as a normal list but instead of looping through a list automatically, you have to keep updating the node that you want to check and if it satisfies the condition given. Also, you have to take into consideration when the list is empty, or when the you reach the end of the list or if the next node is None, or if it's size is 0, and make "if statements" that satisfy those conditons based on your method accordingly. 

We had a lab to do for this concept but unfortunately, without TAs was proven to be very difficult because we didn't have the extra guide to lead us to the right direction especially that it is a new concept. But overall, the lab was not too bad but I still need to practice cases where if the loop reaches the end or if there aren't anything in the list because I tend to miss some important things in my code that will make it run incorrectly. More practice needs to be done with these methods but other than that, not too bad to get my mind around. 

No comments:

Post a Comment