Long Assignment
Long Assignment
dequeue value\n");
REVERSEQ that will printf("3.dispaly\n");
reverse all the elements in
a circular queue printf("4.exit\n");
while(1){ enqueue(no);
printf("\n1.enqueue value\n"); }
} }
rear=-1; for(i=front;i<size;i++){
for(i=0;i<front;i++){ push(i);
scanf("%d",&no); for(i=0;i<=rear;i++){
enqueue(no); push(i);
} }
} }
for(i=rear;i<front-1;i++){ for(i=top;i>=0;i--)
scanf("%d",&no); top=-1;
enqueue(no); }
} if(c==2){
} while(choice!='n'){
} if(front==-1){
}
#include<Stdio.h>
getche();
#define size 11
void enqueue(int); }
int front1=-1; }
for(i=0;i<size;i++){ }
scanf("%d",&value); if(front1==-1)
enqueue(value); front1++;
} rear1++;
//////////////////////////////////// queue1[rear1]=queue[i];
for(i=front;i<=rear;i++){ }
enqueue1(i); if(front2==-1)
} front2++;
else rear2++;
enqueue2(i); queue2[rear2]=queue[i];
} if(flag1==1)
if(choice==1){
#include<Stdio.h>
flag1=1;
#include<stdlib.h>
while(c!='n'){
void atend(int);
printf("\nenter a number: ");
void insertatbeg(int);
scanf("%d",&value);
void middleinsert(int);
atend(value);
void deleteatend();
printf("do you want to enter another
void deleteatstart();
value(y/n):");
void print();
c=getche();
struct node{
}
int data;
c='y';
struct node *next;
}
}*var,*head,*temp,*get,*temp1;
if(choice==2){
int main(){
flag1=1;
int choice,choice1,choice2;
while(c!='n'){
int value,loc;
printf("\nenter a value: ");
int flag=0;
scanf("%d",&value);
char c='y';
insertatbeg(value);
int flag1=0;
printf("do you want to insert another
while(1){ integer(y/n): ");
printf("2.insertion at beginning\n"); }
c='y'; printf("\nenter a number: ");
} scanf("%d",&value);
printf("\n****************************** middleinsert(value);
**************\n");
flag=1;
printf("3.insertion in the middle\n");
if(flag==1)
printf("0.goto next menu or select any
above choice\n"); break;
printf("\n****************************** }
**************\n"); }
printf("select choice: "); if(flag==1)
scanf("%d",&choice); printf("\nnode successfully
if(choice==3){ inserted:\n");
get=head; if(flag==0)
} scanf("%d",&choice1);
else{ printf("\n******************************
*************\n");
if(get->next==NULL){
if(choice1==4){
printf("\nadd node in middle
not at end:\n"); while(c!='n'){
break; get=head;
} deleteatend();
printf("\ndo you want to delete }
another integer(y/n): ");
}
c=getche();
void atend(int value){
}
var=(struct node*)malloc(sizeof(struct
c='y'; node));
} var->data=value;
if(choice1==5){ if(head==NULL){
while(c!='n'){ var->next=NULL;
deleteatstart(); head=var;
temp1=head; var->next=NULL;
print(); head=var;
} temp=head;
if(choice2==7) }
exit(0); else{
var->next=head; get->next=NULL;
head=var; temp=get;
} printf("\nnode deleted
successfully:\n");
}
}
void print(){
deleteatstart(){
printf("\nvalue store in linklist:\n");
head=head->next;
while(temp1!=NULL){
printf("\nnode deleted at start:\n");
printf("%d\n",temp1->data);
if(head==NULL){
temp1=temp1->next;
printf("\nlinklist is empty: \n");
}
}
printf("pointer point at the end of
link list"); }
}
Q#4: Write the following
void middleinsert(int value){
algorithms for the deque
var=(struct node*)malloc(sizeof(struct [double ended queue]
node));
using circular array.
var->data=value;
var->next=get->next; #include<Stdio.h>
} void Insert_dq(int);
} int rear=-1;
} int value,i,c;
char choice='y'; front=-1;
while(1){ rear=-1;
printf("\n1.enqueue\n"); }
printf("2.dequeue\n"); else{
printf("3.display\n"); while(choice!='n'){
int data1;
struct node1 *next1; printf("do you want to enter another
value(y/n):");
}
*var1,*head1,*temp1,*get1,*storage1, choice1=getche();
*sorting1;
}
//////////////////////////////////////////////////////////
////// sorted1();
while(choice!='n'){ get=head;
get=head->next; temp1=head1;
sorting=head; }
while(1){ else{
while(get!=NULL){ var1->next1=NULL;
if(sorting->data>get->data){ temp1->next1=var1;
storage=sorting->data; temp1=var1;
sorting->data=get->data; }
get->data=storage; }
} get1=head1->next1;
else sorting1=head1;
get=get->next; while(1){
} while(get1!=NULL){
sorting=sorting->next; if(sorting1->data1>get1->data1){
get=sorting->next; storage1=sorting1->data1;
if(get==NULL) sorting1->data1=get1->data1;
break; get1->data1=storage1;
} get1=get1->next1;
} }
//////////////////////////////////////////// else
var1=(struct }
node1*)malloc(sizeof(struct node1));
sorting1=sorting1->next1;
var1->data1=value1;
get1=sorting1->next1;
if(head1==NULL){
if(get1==NULL)
var1->next1=NULL;
break; while(get1!=NULL){
} if(get->data==get1->data1){
} printf("%d\n",get->data);
while(get1!=NULL){ }
printf("%d\n",get1->data1); }
get1=get1->next1;
Q#7: Write a function
}
reverse_print which prints
printf("pointer point at the end of the elements of a linked
second linklist"); list in reverse order.
}
int data; }
}*var,*head,*temp,*temp1,*temp2; var->next=NULL;
char choice='y'; }
while(choice!='n'){ }
scanf("%d",&value); printf("\n");
var->data=value; temp2=head;
if(head==NULL){ }
var->next=NULL; printf("%d\n",temp1->data);
head=var; }