2015年3月17日星期二

Slog for week 5 & week 8

Since we had a test on week 8, we didn’t move further on the topic of link list on that week. Thus I decide to combine the slogs for week 5 and week 8.

What’s New?

Link list is a new topic in this course.  It is like making connection between nodes and number, in a format like:

 _________       _________       _________
|_1_|_next_|--->|_2_|_next_|--->|_3_|_next_|


Each node includes an initial value and next value. Initial value could be a number or None, and the next value must be LinkList Node or None.

Connection between LLNode, LinkedList

In the previous lecture, we were talking about Binary Tree. I think the code of LinkedList is very similar to the Binary Tree. (Well, indeed, they are sharing the same data structure but different idea) First, every LinkedList can be broken down into two parts: value and NEXT. NEXT is the next node in this list after the value. Corresponding to these, Binary Tree also has its leading value which called data (it is the ‘root’ of the tree) and left and right children (containing other Binary Tree or None).  However, Binary has its specific rule about putting the number on the root circle and children circle, that is: the value in left children must be less than the number in root circle, while left children is bigger than the root circle. However, LinkedList doesn’t have such a strict rules. Different from Binary Tree, LinkedList focuses more on the feature of linking states (or we usually call it a LinkedList Node, instead of searching and comparing the number in the state.

Difficulties and Challenge

I’m quite confusing on the concept of lnk.front and lnk.back. I know usually lnk.front will represent the whole linkedlist, but what about lnk.back? Under what situation the value of lnk.back changes and what doesn’t?

Furthermore, when I want to insert a value inside a given LinkList, I will record the previous_node first, then move current_node to current_node.nxt and make my target value and current_node.nxt into a new LLNode. After that we need this new node to substitute the previous_node.nxt. So what’s happening on the part before the pervious_node? I’m kind of confusing about the logic here. 

没有评论:

发表评论