COMPSCI 61B Lecture Notes - Lecture 5: Member Variable, Linked List

39 views4 pages

Document Summary

2 lectures ago, we created an intlist which is a powerful recursive data structure. Problem is, intlist is awkward to work with, We"ve created the sllist, which hides some of the nakedness. A: maybe just cache the last node. In order to delete the final item, we need to know where the second to last item is, Answer: no because we need last to point to that afterwards. Solution: what we can do is link the data structure so that it has a previous and a next. Sllist singly linked list has a limitation: Special case: last pointer sometimes points at the sentinal, sometimes at a real node. For each methods, run into annoying if statement that checks sentinal. Instead having two sentinels, have a sentinel that represents both front and back. Add additional sentback sentinel at the end of the list. Make the linked list circular, with a single sentinel in the middle.

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