Goseeko blog

What is a Linked list?

by Bhumika

A linked list (LL) is a collection of elements with the exception that the components are not stored in a sequential order.

If a programmer requests that an integer value stores, the integer value is given the size of a 4-byte memory block. The programmer issued a new request to store three more integer elements; three distinct memory blocks were then allot to these three elements, but the memory blocks were located at random. So, what’s the connection between the elements?

These elements are linked by providing one additional piece of information, namely the address of the next element, with each element. A pointer is a variable that stores the address of the next element. As a result, we can deduce that the LL is made up of two components, the first of which is the data element and the second of which is the pointer.

Fig : linked list 

Declaration of linked list

Because an array is of a single type, declaring it is quite straightforward. However, the LL has two pieces, each of which is of a different type, namely, a simple variable and a pointer variable. The LL declared using the structure user-defined data type.

A linked list’s structure described as follows:

struct node  

{  

   int data;  

   struct node *next;  

}  

We’ve established a structure called a node in the above declaration, which consists of two variables: an integer variable (data) and a pointer (next), which carries the address of the next node.

Advantages 

  • Data structure that is always changing.
  • Insertion and deletion are two different things.
  • Memory-friendly.
  • Implementation.

Disadvantages 

  • Memory consumption.
  • Traversal.
  • Traversing backwards.

Application

  • Memory allocation that is dynamic.
  • Stack and queue implementations.
  • Software’s undo functionality.
  • Graphs, hash tables

Types 

The following are the types of LL:

  • Singly Linked list
  • Doubly Linked list
  • Circular Linked list
  • Doubly Circular Linked list

Interested in learning about similar topics? Here are a few hand-picked blogs for you!

  1. What is Sorting Algorithm?
  2. Explain data structure?
  3. What is Recursion?
  4. Illustrate minimum spanning tree?

You may also like