|
|
Data Structures
So far in this course, we've
discussed Arrays and ArrayLists.
- What are some differences, advantages, and disadvantages of
each?
A linked list is a data structure that allows for easy addition and
removal of elements int he middle of the sequence. Linked lists
are ideal when you want to store an ordered list of objects, but you do
not want to re-sequence the list each time an element is added or
removed.
Instead of using elements and indicies, as Arrays do, linked lists use
nodes. Each node knows about its immediate neighbors, but not
anyone else. So, when you insert a node, you only need to notify
the two neighbor nodes.
With linked lists, random access is slower than an Array or ArrayList
because several elements must be traversed. But, if
nodes are accessed sequentially, inefficiency is not an issue.
More Linked Lists
|