Linked List
Linked List
Linked List
Following are the important terms to understand the concept of Linked List.
• Link − Each link of a linked list can store a data called an element.
• Next − Each link of a linked list contains a link to the next link called Next.
• LinkedList − A Linked List contains the connection link to the first link called First.
Linked List Representation
Linked list can be visualized as a chain of nodes, where every node points to the next node.
As per the above illustration, following are the important points to be considered
• Linked List contains a link element called first.
• Each link carries a data field(s) and a link field called next.
• Each link is linked with its next link using its next link.
• Last link carries a link as null to mark the end of the list.
Basic Operations
Following are the basic operations supported by a list –
Search - You can determine and retrieve a specific node either from
the front, the end, or anywhere in the list.
The worst case Time Complexity for retrieving a node from
anywhere in the list is O(n).
Add - You can add a node at the front, the end or anywhere in the
linked list.
The worst case Time Complexity for performing these operations is as
follows:
•Add item to the front of the list: O(1)
•Add item to the end of the list: O(n)
•Add item to anywhere in the list: O(n)x
Common Singly Linked List Operations:
You can remove a node either from the front, the end or from anywhere in the list.
The worst case Time Complexity for performing this operation is as follows:
• Remove item from the front of the list: O(1)
• Remove item from the end of the list: O(n)
• Remove item from anywhere in the list: O(n)
Circular Linked List
• A circular linked list is a variation of a normal linked list.
• In a circular linked list, as the name suggests, the list does not end; instead, it loops around. The last
element of a circular linked list points to the head instead of pointing to null.
• A circular linked list can be implemented as a singly linked list or a doubly linked list.
• There are three fundamental operations that every linked list does:
1. Add element
2. Delete element
3. Display list
Add element –
• The first link points to the previous node in the list and the second link points to the next node in the list.
• The first node of the list has its previous link pointing to NULL similarly the last node of the list has its
The two links help us to traverse the list in both backward and forward direction. But storing an extra link
requires some extra space.
Quiz
A linear collection of data elements where the linear node is given by means of
pointer is called?
A. Linked List
B. Node List
C. Primitive List
D. None of these
Quiz
Ans : A
Explanation: A linear collection of data elements where the
linear node is given by means of pointer is called linked list.
Quiz
What is the time complexity to count the number of elements in the linked list?
A. O(1)
B. O(n)
C. O(logn)
D. None of the mentioned
Quiz
Ans : B
Explanation: To count the number of elements, you have to traverse through
the entire list, hence complexity is O(n).
Quiz
A. Insertion sort
B. Radix sort
C. Polynomial manipulation
D. Binary search
Quiz
Ans : D
Explanation: Linked lists are not suitable to for the
implementation of Binary search.
Quiz
Ans : D
Explanation: Linked lists can be used to implement all of the above mentioned
applications.
THANK YOU!