mirror of
https://github.com/TheAlgorithms/C
synced 2024-11-22 05:21:49 +03:00
Rename CLL.C to CircularLinkedList.C
This commit is contained in:
parent
104bf2cafc
commit
a3e1817738
@ -1,20 +1,20 @@
|
||||
/* Circularly Linked List (Basic Operations) - Program to create a Circularly linked list abstract data type and perform various operations on it (Variable first and last declared globally) */
|
||||
/* Circularly Linked List (Basic Operations) - Program to create a Circularly linked list abstract data type and perform various operations on it (Variable first and last declared globally) */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <conio.h>
|
||||
#include <stdio.h>
|
||||
#include <conio.h>
|
||||
#include <stdlib.h>
|
||||
#define NULL 0
|
||||
#define NULL 0
|
||||
|
||||
/* Assume that the data portion of each node consists of ONLY an integer.*/
|
||||
/* Assume that the data portion of each node consists of ONLY an integer.*/
|
||||
struct node
|
||||
{
|
||||
int data ;
|
||||
struct node *next ;
|
||||
} ;
|
||||
|
||||
struct node *first=NULL ;
|
||||
struct node *last=NULL ;
|
||||
/* first and last are global variables and need not be passed to any function. Any changes made to variables first and last by any of the functions in the program will be reflected in the entire program */
|
||||
|
||||
struct node *first=NULL ;
|
||||
struct node *last=NULL ;
|
||||
/* first and last are global variables and need not be passed to any function. Any changes made to variables first and last by any of the functions in the program will be reflected in the entire program */
|
||||
|
||||
/* This function is responsible for creating the Circularly Linked List right from the BEGINING. */
|
||||
void create()
|
||||
@ -54,15 +54,15 @@ void deletenode(int k)
|
||||
{
|
||||
struct node *p , *follow ;
|
||||
|
||||
/* searching the required node */
|
||||
p=first ;
|
||||
follow=NULL ;
|
||||
while(follow!=last)
|
||||
{
|
||||
if(p->data==k)
|
||||
break ;
|
||||
follow=p ;
|
||||
p=p->next ;
|
||||
/* searching the required node */
|
||||
p=first ;
|
||||
follow=NULL ;
|
||||
while(follow!=last)
|
||||
{
|
||||
if(p->data==k)
|
||||
break ;
|
||||
follow=p ;
|
||||
p=p->next ;
|
||||
}
|
||||
|
||||
if(follow==last)
|
||||
@ -82,7 +82,7 @@ void deletenode(int k)
|
||||
last->next=first ;
|
||||
}
|
||||
else /* deleting any other node */
|
||||
follow->next=p->next ;
|
||||
follow->next=p->next ;
|
||||
|
||||
free(p) ;
|
||||
}
|
||||
@ -96,7 +96,7 @@ void traverse()
|
||||
printf("Circularly Linked List Empty") ;
|
||||
else
|
||||
{
|
||||
printf("Circularly Linked List is as shown: \n") ;
|
||||
printf("Circularly Linked List is as shown: \n") ;
|
||||
|
||||
p=first ;
|
||||
follow = NULL ;
|
||||
@ -105,7 +105,7 @@ void traverse()
|
||||
printf("%d " , p->data) ;
|
||||
follow=p ;
|
||||
p=p->next ;
|
||||
}
|
||||
}
|
||||
|
||||
printf("\n") ;
|
||||
}
|
||||
@ -146,10 +146,10 @@ void main()
|
||||
break ;
|
||||
}
|
||||
}
|
||||
while(ch!=4) ;
|
||||
while(ch!=4) ;
|
||||
|
||||
getch() ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user