Week #9: Linked Lists
In the last week, I first experienced a strike of TA, which is really a new one for me. Although there is no tutorial last week, there is a lab to train myself, which I think is really hard comparing to last all 6 labs. But the most important thing I learn from this lab is following the guide from professors, drawing pictures!
Drawing pictures really means a lot to implementing a LinkedList function. For we need to know and focus on what our linked structures should look like before, during and after operations where we change and mutate the structures. I think the function insert_before is quite important to comprehend the utility of the previous node, current node, lnk.front and drawing pictures.
First thing we need to concentrate on is setting up the prev.node and cur.node and the condition to start this function, i.e. the lnk node is not empty. After we have set the arguments, we next want to find the situation, the node starting with v2, where we want to insert our value v1. So we use while loop just like reading a file in csc108 last term. We need to notice that, every time we change the state to the next step, we are not using a new id or say a new variable. We are using the variables forming the lnk node, which means if we change the cur.node, prev.node or something related to cur.node, prev.node we are also changing the lnk node at the same time. This is the nature why we can use this type of solutions to implement the function like insert_before or some other LinkedList functions.
Recommend: http://csc148slog1001429162.blogspot.ca/2015/03/linked-lists.html?showComment=1428298701184#c7835146733346258866
Same idea as me, but much more beautiful pages design!
Drawing pictures really means a lot to implementing a LinkedList function. For we need to know and focus on what our linked structures should look like before, during and after operations where we change and mutate the structures. I think the function insert_before is quite important to comprehend the utility of the previous node, current node, lnk.front and drawing pictures.
First thing we need to concentrate on is setting up the prev.node and cur.node and the condition to start this function, i.e. the lnk node is not empty. After we have set the arguments, we next want to find the situation, the node starting with v2, where we want to insert our value v1. So we use while loop just like reading a file in csc108 last term. We need to notice that, every time we change the state to the next step, we are not using a new id or say a new variable. We are using the variables forming the lnk node, which means if we change the cur.node, prev.node or something related to cur.node, prev.node we are also changing the lnk node at the same time. This is the nature why we can use this type of solutions to implement the function like insert_before or some other LinkedList functions.
Recommend: http://csc148slog1001429162.blogspot.ca/2015/03/linked-lists.html?showComment=1428298701184#c7835146733346258866
Same idea as me, but much more beautiful pages design!
No comments:
Post a Comment