CSC148H1 Lecture Notes - Lecture 12: Linked List

116 views4 pages
School
Course
Professor
katrinasavvy and 38715 others unlocked
CSC148H1 Full Course Notes
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.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents