Introduction to Linked List Data Structure and Algorithm Tutorials (original) (raw)

Last Updated : 22 Oct, 2024

**Linked List is basically chains of nodes where each node contains information such as **data and a **pointer to the next node in the chain. It is a popular data structure with a wide range of real-world applications. Unlike Arrays, Linked List elements are not stored at a contiguous location. In the linked list there is a **head pointer, which points to the first element of the linked list, and if the list is empty then it simply points to null or nothing.

In this article, we will provide a complete introduction of Linked List, which will help you tackle any problem based on Linked List.

Basic Terminologies of Linked List

Importance of Linked List

Here are a few advantages of a linked list that is listed below, it will help you understand why it is necessary to know.

Implementations of Basic Operations on Different Types of List

Basic Operations on Singly Linked List

The following are some basic operations performed on a Single Linked List:

**Operations on Doubly Linked List:

In a doubly linked list, we perform the following operations...

**Commonly used operations on Circular Linked List:

The following operations are performed on a Circular Linked List

Linked List vs. Array:

Array Linked List
Arrays are stored in contiguous location. Linked Lists are not stored in contiguous location.
Fixed size (Dynamic Sized Arrays also internally use fixed sized arrays) Dynamic Size
Only store elements no extra reference / pointer. It stores both data and address of next node.
Elements can be accessed easily in O(1) time. Elements can be access by traversing through all the nodes till we reach the required node.
Insertion and deletion operation is slower than Linked List. Insertion and deletion operation is faster than Array.

Time Complexity Analysis of Linked List and Array:

Operation Linked list Array
Random Access O(N) O(1)
Insertion and deletion at beginning O(1) O(N)
Insertion and deletion at end O(N) (If we maintain only head) O(1)
Insertion and deletion at a random position O(N) O(N)

Please refer Applications, Advantages and Disadvantages of Linked List for more details

Conclusion:

There are many advantages of the linked list compared to array, despite the fact that they solve the similar problem to arrays, we have also discussed the advantage, disadvantages, and its application, and we concluded the fact that we can use a linked list if we need the dynamic size of storage and list are good for adding and removing items quickly or for tasks that require sequence but are not suitable for querying or search elements in a large collection of data.

So, it becomes important that we should always keep in mind the **positive and **negative aspects of a **data structure and how they relate to the problem you are trying to solve.

**Related articles: