CSC148H1 Lecture Notes - Lecture 12: Linked List
katrinasavvy and 38715 others unlocked
1
CSC148H1 Full Course Notes
Verified Note
1 document
Document Summary
References: code seen in the pictures can be found on the csc148 website: http://www. teach. cs. toronto. edu/~csc148h/winter/ Add a node with new value to he end of the list. Need to change: last node, former last node, size, back, possibly front (if size of linked list was originally 0) 2 cases: empty linked list, non empty linked list. New_node = linkedlistnode(value: creating new node self. front = self. back = new_node. If self. back. next = new_node is after self. back = new_node, the last node will point to itself self. back = new_node. If the list isn"t empty, front stay the same self. size += 1: don"t forget to increase the size of the linked list. List-based queue has problem: adding or removing will be slow. If one element is removed from position 0, it has to move all elements in queue one step over: when doing it many times, it takes a longer amount of time.