1.4.2 Linked Lists, Trees and Graphs
1.4.2 Linked Lists, Trees and Graphs
Science
1.4.2. Data Structures
Linked-Lists, Trees and Graphs
Specification
Recap
A linked list is a list of data items where each item contains data
together with a pointer to the next item in the list.
Linked lists are typically used to access data in a particular order
even if they are not stored in order or even in adjacent memory
spaces.
Linked lists can be doubly linked, i.e. they can link to the previous
item in the list too.
A linked list needs a pointer to indicate the head or first item in the
list.
(Terminator)
An unconnected link is called a null pointer or terminator.
Hea
d
Linked Lists Operations
The typical linked list operations are insertion, deletion, display and
find.
Insertion is the adding of a data item into the list into a position that
maintains the defining order of the list.
Deletion is the removal of a data item from a list, maintain its
defining order.
Display the complete list.
Find or search looks for a specific element using a given key.
Display and find are traversal operations.
Liked list insertion
Adding a new node in linked list is a more than one step activity.
Step 1, create a node using the same structure and find the location
where it has to be inserted.
Imagine we are inserting a new node B between node A and node C.
Linked list insertion
Step 2, make the new node B point to node C.