CSC 111 Lecture Notes - Lecture 10: Random Access, Sequential Access, Instance Variable

46 views3 pages

Document Summary

Array-based linked list: comparisons between linked list and array, arra(cid:455) (cid:272)a(cid:374)(cid:859)t (cid:272)ha(cid:374)ge size o(cid:374)(cid:272)e it is de(cid:272)lared, array- Linked list can: static fixed length, add/remove requires data movement, random access (index, linked list, dynamic change length, add/remove without moving data. Just change the pointers: sequential access (head, tail pointer, head pointer points to beginning, tail pointer points to the last node/item. Initialize the next column that points to the next item in line: add(cid:894)(cid:858)(cid:272)(cid:859)(cid:895) Head = 0 numitems = 1 free = 1. Head = 0 numitems = 1 free = 1 head = 0 numitems = 2 free = 2. Head = 0 numitems = 3 free = 3. 1 sta(cid:374)ds for (cid:374)ull (cid:373)ea(cid:374)i(cid:374)g that i(cid:374) the last e(cid:454)a(cid:373)ple, (cid:858)t(cid:859) is poi(cid:374)ti(cid:374)g to (cid:374)ull and the list ends at t basically. Head = 0 numitems = 2 free = 1. Index is 3 for a because it is the next thing that will be overwritten and such.

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers

Related Documents