Group Discounts available for 3+ students and Corporate Clients

# Circular linked list in Data Structures

A linked list in which the last node points to the first node instead of containing null pointer will be termed as circularly linked list or simply circular list

Circular linked list in data structures have an advantages over singly linked list. It is concerned with the accessibility of a node. Ina circular list every node is accessible from a given node that is, from this given node all nodes can be reached by changing through the list.

### Insertion operation:

1. Insertion as a first node:

## Deletion Operation

• ### Deleting first node

free(ptr);

• Deleting a specific node

free(temp);

### Circular linked list Program in Data Structures

# include <studio.h>

#include <conio.h>

# define NULL

#include<stdlib.h>

struct Node

{

int data;

};

void create()

{

int a;

struct Node * cur,*ptr;

printf(“Enter Data For The Node(-1):”);

scanf(“%d%,&a);

while(a!=-1)

{

cur =(struct Node *) malloc (size of (struct Node));

curdata =a;

else

ptr= cur;

printf(“Enter Data For Node (-1):”);

scanf (“%d”,&a);

}

}

void insert()

{

int ele;

char ch;

struct Node*ftr, *ptr,*ptr1,*cur;

cur=(struct Node *) malloc (size of (struct Nodes);

printf(“Enter data:”);

scanf(“%d”,&cur àdata);

printf(“Do you want to insert first(y\n):”);

flush(stdin);

scanf(“%c”,&ch);

if((ch==’y’) || (ch==’y’))

{

{

}

}

else

{

printf(“After which element you want to insert:”);

scanf(“%d”,&ele);

do

{

if( ptr1 data == ele)

{

}

}

}

}

void deletion()

{

int ele;

char ch;

struct Node *temp,*ptr,*ptr1;

fflush(stdin);

printf(“Do you want to delete first(y\n):”);

scanf(“%c”,&ch);

if((ch==’y’)|| (ch==’y’))

{

{

}

}

else

{

printf(“After which element you want to insert:”);

scanf(“%d”,&ele);

do

{

if(ptr1  data ==ele)

{

}

}

}

}

void deletion()

{

int ele;

char ch;

struct Node *temp,*ptr,*ptr1;

fflush(stdin);

printf(“Do you want to delete first (y/n):”);

scanf(“%c”,&ch);

if((ch==’y’) || (ch==’y’))

{

{

}

free(ptr1);

}

printf(“Which element you want to delete:”);

scanf(“%d”,&ele);

do

{

{

free(temp);

break;

}

else

{

}

}

}

void display()

{

struct Node * temp;

do

{

printf(“%d” ,temp  data);

}

}

}

void main()

{

int op;

clrscr();

create();

printf(“1.INSERTION \n”);

printf(“2.DELETION  \n”);

printf(“3.DISPLAY  \n”);

printf(“4.EXIT \n”);

do

{

scanf(“%d”,&op);

switch (op)

{

{

case1: insertion (); break;

case2: deletion (); break;

case3: Display(); break;

case4: exit(0);

}

}

while (op<=4);

}