Open In App

Basic Terminologies of Linked List

Last Updated : 20 Oct, 2024
Summarize
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

Linked List is a linear data structure, in which elements are not stored at a contiguous location, rather they are linked using pointers. Linked List forms a series of connected nodes, where each node stores the data and the address of the next node.

What is Linked List

Node Structure: A node in a linked list typically consists of two components:

  1. Data: It holds the actual value or data associated with the node.
  2. Next Pointer or Reference : It stores the memory address (reference) of the next node in the sequence.

Head and Tail: The linked list is accessed through the head node, which points to the first node in the list. The last node in the list points to NULL or nullptr, indicating the end of the list. This node is known as the tail node.

Why linked list data structure needed?

The main cases where we prefer linked list over arrays is due to ease of insertion and deletion in linked list

Example: 

In a system, if we maintain a sorted list of IDs in an array id[] = [1000, 1010, 1050, 2000, 2040]. 

If we want to insert a new ID 1005, then to maintain the sorted order, we have to move all the elements after 1000 (excluding 1000). 

Deletion is also expensive with arrays until unless some special techniques are used. For example, to delete 1010 in id[], everything after 1010 has to be moved due to this so much work is being done which affects the efficiency of the code.

Please refer Applications, Advantages and Disadvantages of Linked List for more detailed use cases of linked list. Also, refer Types of Linked List to know about different types of linked lists for different applications.

Operations on Linked Lists

  1. Insertion: Adding a new node to a linked list involves adjusting the pointers of the existing nodes to maintain the proper sequence. Insertion can be performed at the beginning, end, or any position within the list
  2. Deletion: Removing a node from a linked list requires adjusting the pointers of the neighboring nodes to bridge the gap left by the deleted node. Deletion can be performed at the beginning, end, or any position within the list.
  3. Searching: Searching for a specific value in a linked list involves traversing the list from the head node until the value is found or the end of the list is reached.

Please refer Complexity Analysis of Linked List for time complexities of different operations of linked list.


Next Article
Article Tags :
Practice Tags :

Similar Reads

three90RightbarBannerImg
  翻译: