Workshop 6 - Linked Lists Flashcards
Linked List
Collection of objects, called nodes.
Every node has two components, INFORMATION to be stored and REFRENCE to the next node.
Dyanmic Data Structure
Linked List is an example of this.
Number of nodes can grow if not fixed list.
Linked List can grow and shrink on demand.
Linked List advantages
Easily extendable or reduced to fit in data set.
Efficient - O(1) to insert/delete, ONCE LOCATED.
Linked List disadvantages
Does not allow direct access to individual items.
To find particular item, start at head and follow references till you get to the item. O(n)
Uses more memory. NEED to store a reference to next node.
Representation of Single Linked List in Java
recursive definition
data - integer
link - refrence table
Linked List example.
How do you know you reached end of queue?
How do you knkow if item removed?
What happens if you start at the start?
refrence link value = returns null value
you dont get acess to the other nodes.
you cannot. linking in one direction. no information about predessor.
Dummy Node
gives null value
Doubly Linked Liust
One more refrence, more flexibility.
more space disadvanatge,
SkipList
Probablistic data structure.
Based on set of parallel linked lists.
Improved efficiency.
SkipList data stored in order.
During search it parts of list can be skipped.
Efficiency O(log2n)