Linked List

It is a type of data structure in which we overcome the shortcomings of an array.

An array is a very useful data structure provided in programming languages. However, it has at least two limitations:

  1. Its size has to be known at compilation time
  2. The data in the array are separated in computer memory by the same distance, which means that inserting an item inside the array requires shifting other data in this array.

Untitled

Implementation

As we know that the array is contagious, we can never insert any or remove any element directly from any positions instead we have to move or copy the whole array then insert it along with the addition. We can also never extend the array hence making it hard and requires another array to be used to store the current order Note: A linked list is a combinations of nodes connected to each other w.r.t to there address pointer.

What are Singly linked list?

A linked list consists of 2 blocks (info and next), one for the data of the list and one for the address which links it to other linked list. It is singly linked to its successor only, hence that's why it is singly listed

When a linked list is connected to only one successor further then it is called a singly linked list(jab wo further sirf ek LL se connected ho)

linked list is in the form of 2 boxes known as nodes containing data (info) and pointer address (next)

The definition and calling of the linked list requires 2 constructors

constructor one creates an empty node which creates empty data box and pointer value null for our linked list (basically initializing it)

constructor 2 allocates/moves/inputs the data and address of your linked list in the newly created node by the first constructor.

Linked list IS LINKED meaning there are should be 2 or more created to assign the base address of the first linked list to the second. if there is nolink for the last base addressed pointer, then it will be an automatic null/terminator pointer