SYSC 2100 Lecture Notes - Lecture 6: Linked List

85 views3 pages

Document Summary

Note: this keyword refers to the attribute of the class. Determining the point of insertion or deletion for a sorted linked list: - 1 for (prev = null, curr = head; 3 prev = curr, curr = curr. getnext()) { Equivalent to: for(int i = 0; i < n; i++) Another way of saying: "use a linked list!" Does not shift items during insertions and deletions. Does not impose a fixed maximum length on the list. 1 // locates a specified node in a linked list. 2 // returns a reference to the desired node. 5 for (int skip = 0; skip < index; skip++) { Comparing array - based and reference - based implementation. Less memory: no need to store explicit information about reference. More storage: an item explicitly references the next item in the list. Time to access ith node depends on i. Do not require you to shift the data.

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