Saturday, March 20, 2021

linked list in C | and their functions in data structure

 linked list :

a linked collection of data element which are stored at ranf=dom memory location and linked to one another the order among element is given by mean of links i e each item is linked to another item 

types of linked list 

1. singly linked list 

2. doubly llinked list 

3. singly circular linked list 

doubly circular linked list


1. singly linked list :

Each node in the list contain only one pointer which points to the next  node of the list The pointer in the last node stores NULL

Node structure :

 struct node                         

{

int info;

struct node next;

}

2. Doubly linked list :

Each node in the list contain two pointers on pointing to the previous node and the other pointing to the next node this list is used when we want to traverse the list in both directions.

Node structure:

struct node 

{

int info;

struct node *prev, *next;

};

3. Singly circular linked list :

This is a singly linked list in which the last node points to the first node . i . e it contain the address of the first node. 


4. Doubly circular linked list :

This is a doubly linked list in which the last node points to the first  and the first node points to the last .

operations on linked list :

teh various operation that can be performed on the linked list :

1, CREATE :  create a list of n nodes.

2. TRAVERSE : Visit each node of the list .

3. LENGTH :  Count the total numbers in the list.

4. INSERT : A node can be inserted at the beginning at end and in between the two nodes 5;

5. DELETE: The deletion  may be done either position wise or element wise .

6.SEARH : This process searches for a specific element in the list.

7 REVERSE: This process reverse the order of node in the list.

8. CONCATENATE: This operation apends the node of the second list of the end of the first list i . e it join two lists .

9. MERGE: This operation merge two sorted list in to a third list such that the third list is also in sorted order.









0 comments:

Post a Comment