Linked List

A linked list is a list type data structure that contains a collection of Data elements where the order of physical arrangement is not continuous i.e. unlike in array where the memory allocated is continuous.

  • Video explanation from YouTube.


In Linked List each data element is represented by a Node. A typical representation of a node of a singly linked list (explained below) is given below.

Hence we can represent a Linked List as a collection of such nodes.


Figure 1: Node

Operations associated with the linked list are insertion at any position,deletion at 
any point and search.


Types of Linked List :

a)singly linked list(discussed in this article)
b)doubly linked list
c)circular linked list

A. Singly-linked list :

A singly linked is a list where each node except the last has the address of its next
node and last node points to Null.

We implement Linked List with the help of structures(keyword struct) or a
class with a Pointer (Head) of type that of Node, which stores the link(Address) to the starting of the list which is then iterated till we reach the node with Null.

Here we travel through each element linearly that is to reach at any Node we have to travel all the nodes before it until and unless we have the address of that node.

Representation :

  


Code :

Hand simulation of the code:





Hoping that you understood singly Linked List, here are some problems for you:

BASICS Problems :

   
      1. Print the elements of the linked list
      2. Insert a node at the tail of a linked list
      3. Insert a node at a specific position
      4. Delete a node
      5. Reverse a linked list

In the next article, we will be discussing Doubly linked list.
If you have any doubt or any suggestions please comment below

Thank you

Comments