Singly Linked List

A singly linked list is a linear data structure in which the elements are not stored in contiguous memory locations and each element is connected only to its next element using a pointer.

The elements in a linked list are linked using pointers to the next node as shown in the below image:


Singly Linked List

Operations on Singly Linked List:

  • Insertion at the beginning of the Linked List: To insert a node at the beginning of the Linked List, we change the next pointer of the new node to the current head and make the new node as the current head. Time Complexity: O(1)
  • Insertion at the end or after a given node: To insert a node after a given node, we need to update the next pointer of the new node to the next pointer of the given node and update the next pointer of the given node to the new node. Time Complexity: O(N) as in the worst case we may traverse through all the nodes of the linked list.
  • Searching an element: We can search a node by traversing through the linked list and comparing the nodes one by one. Time Complexity: O(N)
  • Find length of the Linked List: We can find the length of the linked list by traversing through the linked list and maintaining the count of nodes. Time Complexity: O(N)
  • Reverse a Linked List: We can reverse a linked list using three pointers currprev, and next to keep track of nodes to update reverse links. Time Complexity: O(N)
  • Deletion at the beginning of the Linked List: To delete a node from the beginning of the Linked List, we can change the head to the next of the current head and delete the previous head. Time Complexity: O(1)
  • Deletion at the end or after a given node: To delete a node after a given node, we need to update the next pointer of the given node to point to the node which is present after the node to be deleted. Time Complexity: O(N) as in the worst case we may traverse through all the nodes of the linked list.

Linked List Notes for GATE Exam [2024]

The “Linked List Notes for GATE Exam” is a comprehensive resource designed to aid students in preparing for the Graduate Aptitude Test in Engineering (GATE). Focused specifically on the topic of linked lists, a fundamental data structure in computer science, these notes offer a detailed and structured approach to mastering this subject within the context of the GATE examination.

Table of Content

  • What is Linked List?
  • Singly Linked List
  • Doubly Linked List
  • Circular Linked List
  • Applications of Linked List
  • Advantages of Linked Lists
  • Disadvantages of Linked Lists
  • Previous Year GATE Questions on Linked List:

Similar Reads

What is Linked List?

A linked list is a linear data structure, in which the elements are not stored at contiguous memory locations. Linked list consists of nodes where each node contains a data field and a reference(link) to the next node in the list....

Singly Linked List:

A singly linked list is a linear data structure in which the elements are not stored in contiguous memory locations and each element is connected only to its next element using a pointer....

Doubly Linked List:

A doubly linked list (DLL) is a special type of linked list in which each node contains a pointer to the previous node as well as the next node of the linked list....

Circular Linked List:

The circular linked list is a linked list where all nodes are connected to form a circle. In a circular linked list, the first node and the last node are connected to each other which forms a circle. There is no NULL at the end....

Applications of Linked List:

Image viewer – Previous and next images are linked and can be accessed by the next and previous buttons.Previous and next page in a web browser – We can access the previous and next URL searched in a web browser by pressing the back and next buttons since they are linked as a linked list.Music Player – Songs in the music player are linked to the previous and next songs. So you can play songs either from starting or ending of the list.GPS navigation systems– Linked lists can be used to store and manage a list of locations and routes, allowing users to easily navigate to their desired destination....

Advantages of Linked Lists:

Dynamic Size: Linked lists can grow or shrink dynamically, as memory allocation is done at runtime.Insertion and Deletion: Adding or removing elements from a linked list is efficient, especially for large lists.Flexibility: Linked lists can be easily reorganized and modified without requiring a contiguous block of memory....

Disadvantages of Linked Lists:

Random Access: Unlike arrays, linked lists do not allow direct access to elements by index. Traversal is required to reach a specific node.Extra Memory: Linked lists require additional memory for storing the pointers, compared to arrays....

Gate Archives on Linked List:

Q1. Consider the problem of reversing a singly linked list. To take an example, given the linked list below,...