Sunday, March 15, 2015

week9 :my impressions of week 8( LLnode and LinkedList)

This week we talked about LinkedList and LLnode.

LLnode is just a single node.

A linked list is a linear sequence of nodes. Each node has a value and a child which keeps reference to the next node. It also has a parameter called front and another parameter called back. "Front" refers to the first node of the sequence.But it has a child which refers to the second node. "Back" refers to the last node of the sequence. But its child is a "None".


For me, this week's material is even harder than recursion!
On Monday's lecture, I was really confused by the difference of LLnode and LinkedList. Because both of them have a child and both of them have a value.
I also couldn't tell the difference between some concepts which occur in codes. (For example: "front","next node","current node".)
After class I asked my professor for help. She showed me a picture(as following)








Just as indicated, "Back" is the last node of a sequence and "front" is the first. However, "front" contains a child. So, in fact "front" indicates the whole sequence. But we often use the expression "current_node = front". In this case,
we can use "current_node = current_node.next" to move forward.
By the way the difference between LinkedList and LLnode is that LinkedList is consisted of LLnode.




















Like the code above, we want to get the value of a particular node. So we use expression " current_node = front" to initialize and "current_node = current_node.nxt" to move forward.
INSIGHT: we can't write "current_node.next" because next if a function in python.

No comments:

Post a Comment