Linked List

Linked List
Linked List

 Linked List

Data Structure

Data structure is a particular way of storing and organizing data in a computer so that it can be used efficiently.

Classification:

Two major classification of data structure are:

  1. Linear data structure (Linked list, stack, queue etc)
  2. Non Linear data structure (tree, graph)

Linked List

Linked List is a Data structure used for storing collections of data.

Linked List has following property:

  • Successive elements are connected by pointers.
  • Last element point to Null (except Circuler Linked List).
  • It can grow or shrink size during execution of a program.
  • It can be made just as long as required.
  • It does not waste memory space.

  Diagrammatic Representation

Linked List, Singly Linked List
Singly Linked List

 

➝There are three main Linked List operations

  1. Insertion
  2. Deletion
  3. Traversing
 

Node 

When we talk about storing List of Information, each information set is a node which also plays a role of connection point in the list.

 Defining a node (Data Type) in Singly Linked List

struct node

{

    int data;

    struct node *next;

};

Linked List, Node
node


Doubly Linked List

Doubly Linked List contains one extra pointer as compare to the node of Singly Linked List.

From any node we can traverse in both the direction.

 Diagrammatic Representation

Doubly Linked List


 

Defining a node (Data Type) in Doubly Linked List

struct node

{

    int data;

    struct node *prev, *next;

};

Doubly Linked List, node
node

 

Circular Linked List

Linked List in which next pointer field (link field) of the last node contain the address of the first node instead of NULL pointer is called Circular Linked List

 

Diagrammatic Representation

Circular Linked List
Circular Linked LIst

 

 Condition for underflow or List is empty:

                            Start = = NULL

Condition for overflow:

                             temp= = NULL  

            {Here temp is a temporary pointer variable}

Condition for only one node in CLL:

                    Start = = Start -> next

Circular Linked List

     Only one node in CLL

 

 

 

 

Post a Comment

0 Comments