Linked list

A linked list is a linear data structure in which elements are not stored at contiguous memory locations. The elements in a linked list are linked using pointers as shown in the below image: 

Types of linked lists:

  • Singly-linked list
  • Doubly linked list
  • Circular linked list
  • Doubly circular linked list

Linked List

Characteristics of a Linked list: 

A linked list has various characteristics which are as follows:

  • A linked list uses extra memory to store links.
  • During the initialization of the linked list, there is no need to know the size of the elements.
  • Linked lists are used to implement stacks, queues, graphs, etc.
  • The first node of the linked list is called the Head.
  • The next pointer of the last node always points to NULL.
  • In a linked list, insertion and deletion are possible easily.
  • Each node of the linked list consists of a pointer/link which is the address of the next node.
  • Linked lists can shrink or grow at any point in time easily.

Operations performed on Linked list:

A linked list is a linear data structure where each node contains a value and a reference to the next node. Here are some common operations performed on linked lists:

  • Initialization: A linked list can be initialized by creating a head node with a reference to the first node. Each subsequent node contains a value and a reference to the next node.
  • Inserting elements: Elements can be inserted at the head, tail, or at a specific position in the linked list.
  • Deleting elements: Elements can be deleted from the linked list by updating the reference of the previous node to point to the next node, effectively removing the current node from the list.
  • Searching for elements: Linked lists can be searched for a specific element by starting from the head node and following the references to the next nodes until the desired element is found.
  • Updating elements: Elements in a linked list can be updated by modifying the value of a specific node.
  • Traversing elements: The elements in a linked list can be traversed by starting from the head node and following the references to the next nodes until the end of the list is reached.
  • Reversing a linked list: The linked list can be reversed by updating the references of each node so that they point to the previous node instead of the next node.

These are some of the most common operations performed on linked lists. The specific operations and algorithms used may vary based on the requirements of the problem and the programming language used.

Applications of the Linked list: 

Different applications of linked lists are as follows:

  • Linked lists are used to implement stacks, queues, graphs, etc.
  • Linked lists are used to perform arithmetic operations on long integers.
  • It is used for the representation of sparse matrices.
  • It is used in the linked allocation of files.
  • It helps in memory management.
  • It is used in the representation of Polynomial Manipulation where each polynomial term represents a node in the linked list.
  • Linked lists are used to display image containers. Users can visit past, current, and next images.
  • They are used to store the history of the visited page.
  • They are used to perform undo operations.
  • Linked are used in software development where they indicate the correct syntax of a tag.
  • Linked lists are used to display social media feeds. 

Real-Life Applications of a Linked list: 

  • A linked list is used in Round-Robin scheduling to keep track of the turn in multiplayer games.
  • It is used in image viewer. The previous and next images are linked, and hence can be accessed by the previous and next buttons.
  • In a music playlist, songs are linked to the previous and next songs. 

Want to get started with a linked list? You can try out our curated articles and lists for the best practice:

Data Structure Types, Classifications and Applications

Similar Reads

What is Data Structure:

A data structure is a storage that is used to store and organize data. It is a way of arranging data on a computer so that it can be accessed and updated efficiently....

How Data Structure varies from Data Type:

We already have learned about data structure. Many times, what happens is that people get confused between data type and data structure. So let’s see a few differences between data type and data structure to make it clear....

Classification of Data Structure:

Data structure has many different uses in our daily life. There are many different data structures that are used to solve different mathematical and logical problems. By using data structure, one can organize and process a very large amount of data in a relatively short period. Let’s look at different data structures that are used in different situations....

Need Of Data structure :

The structure of the data and the synthesis of the algorithm are relative to each other. Data presentation must be easy to understand so the developer, as well as the user, can make an efficient implementation of the operation.Data structures provide an easy way of organizing, retrieving, managing, and storing data.Here is a list of the needs for data....

Arrays:

An array is a linear data structure and it is a collection of items stored at contiguous memory locations. The idea is to store multiple items of the same type together in one place. It allows the processing of a large amount of data in a relatively short period. The first element of the array is indexed by a subscript of 0. There are different operations possible in an array, like Searching, Sorting, Inserting, Traversing, Reversing, and Deleting....

Linked list:

A linked list is a linear data structure in which elements are not stored at contiguous memory locations. The elements in a linked list are linked using pointers as shown in the below image:...

Stack:

Stack is a linear data structure that follows a particular order in which the operations are performed. The order is LIFO(Last in first out). Entering and retrieving data is possible from only one end. The entering and retrieving of data is also called push and pop operation in a stack. There are different operations possible in a stack like reversing a stack using recursion, Sorting, Deleting the middle element of a stack, etc....

Queue:

Queue is a linear data structure that follows a particular order in which the operations are performed. The order is First In First Out(FIFO) i.e. the data item stored first will be accessed first. In this, entering and retrieving data is not done from only one end. An example of a queue is any queue of consumers for a resource where the consumer that came first is served first. Different operations are performed on a Queue like Reversing a Queue (with or without using recursion), Reversing the first K elements of a Queue, etc. A few basic operations performed In Queue are enqueue, dequeue, front, rear, etc....

Tree:

A tree is a non-linear and hierarchical data structure where the elements are arranged in a tree-like structure. In a tree, the topmost node is called the root node. Each node contains some data, and data can be of any type. It consists of a central node, structural nodes, and sub-nodes which are connected via edges. Different tree data structures allow quicker and easier access to the data as it is a non-linear data structure. A tree has various terminologies like Node, Root, Edge, Height of a tree, Degree of a tree, etc....

Graph:

A graph is a non-linear data structure that consists of vertices (or nodes) and edges. It consists of a finite set of vertices and set of edges that connect a pair of nodes. The graph is used to solve the most challenging and complex programming problems. It has different terminologies which are Path, Degree, Adjacent vertices, Connected components, etc....

Conclusion

Although these are the most widely known and used data structures, there are some other forms of data structures as well which are used in Computer Science, such as policy-based data structures, etc. But no matter which data structure you choose, each one has its perks and disadvantages, without the knowledge of which, it can be very costly to choose the wrong type of data structure. So it is very important to understand the need of the situation, and then decide which kind of data structure suits best for the job....