COMPSCI 61B Lecture 5: DLLists, Arrays

55 views5 pages
2 Feb 2019
School
Professor

Document Summary

Inserting at the back of an sllist is much slower than the front because for a long list, the addlist method has to walk through the entire list. We can attempt to speed things up by adding a last variable to speed up our code (like size). This structure will support rapid addlast and getlast but removelast will still be slow because we have no easy way to get to the second-to-last node, to update the last pointer, after removing the last node. Realize that if every node had a pointer to the element behind it, we would never have to scan our node from the front to find the predecessor. Add a backwards link from every node. This yields a doubly linked list or dllist rather than our earlier singly linked list or. Reverse pointers allow all operations to be fast.

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