{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

20090306-LinkedList-I

20090306-LinkedList-I - Advantages/Disadvantages •...

Info iconThis preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon
Lists • We’ve seen an array-based list implementation, the ArrayList. • Advantage of an array-based implementation: – fast access to a specific index – typically less space usage than other options • Disadvantage of an array-based implementation: – can be expensive to insert items – resizing is an expensive operation
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Amortization • Resizing of array-based data structures involves a tradeoff: – many insertions (as in our Bag) are very efficient since no allocation of space is required (an array is allocated as a big block of memory) – some insertions (as in our Bag) are very expensive since resizing must take place
Background image of page 2
Linked List • A linked list is a list implementation which spreads out the cost of space allocation evenly to all insertions. • Each insertion involves allocation of space
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Background image of page 4
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Background image of page 6
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Advantages/Disadvantages • Advantages – predictable cost of insertion – efficient insertion at any point in structure • Disadvantages – extra space required to store links – inefficient indexing Comparison of storage A pair has a first and a second element When pairs are used to construct lists, the first is called the “head” or the “car” the second is called the “tail”, “rest” or “cdr” the pair is called a “cons cell” or simply a “cons”. Linked list implementations • Textbook discusses a typical linked list implementation • java.util.LinkedList is another typical implementation • These implementations have procedural, not object-oriented, roots....
View Full Document

{[ snackBarMessage ]}

Page1 / 6

20090306-LinkedList-I - Advantages/Disadvantages •...

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document Right Arrow Icon bookmark
Ask a homework question - tutors are online