SlideShare una empresa de Scribd logo
1 de 3
Descargar para leer sin conexión
S5-2
Write a program in ‘C’ language to implement a Dequeue using pointers.
All operations associated with a Dequeue are to be implemented.
#include<stdio.h>
#include<conio.h>
struct node
{
int data;
struct node *link;};
void addqatend(struct node**,struct node**,int);
void addqatbeg(struct node**,struct node**,int);
delqatbeg(struct node**,struct node**);
delqatend(struct node**,struct node**);
main()
{
struct node*front,*rear;
int item;
front=rear=NULL;
addqatend(&front,&rear,11);
addqatend(&front,&rear,81);
addqatend(&front,&rear,16);
addqatend(&front,&rear,45);
addqatbeg(&front,&rear,20);
clrscr();
q_display(front);
printf("nnumber of elements in the que=%d",count(front));
printf("nitems taken from qn");
item=delqatbeg(&front,&rear);
printf("%d ",item);
printf("nafter deletionn");
q_display(front);
getch();
}
/*adds a new element at end **/
void addqatend(struct node **f,struct node **r,int item)
{
struct node *q;
q=(struct node*)malloc(sizeof(struct node));
q->data=item;
q->link=NULL;
/**if q empty**/
if(*f==NULL)
*f=q;
else
(*r)->link=q;
*r=q;
}
/*add at begin**/
void addqatbeg(struct node** f,struct node** r,int item)
{
struct node *q;
int t;
Page 1
S5-2
q=(struct node*)malloc(sizeof(struct node));
q->data=item;
q->link=NULL;
/**if q empty**/
if(*f==NULL)
*f=*r=q;
else
q->link=*f;
*r=*f;
*f=q;
}
/*remove from front ***/
delqatbeg(struct node** f,struct node** r)
{
struct node *q; int item;
if(*f==NULL)
printf("q empty");
else
q=*f;item=q->data;
*f=q->link; free(q);
/*if q becom empty after delet*/
if(*f==NULL)
*r=NULL;
return item;
}
/*remove from rear end ***/
delqatend(struct node** f,struct node** r)
{
struct node *q,*rleft,*temp; int item;
temp=*f;
if(*r==NULL)
printf("q empty");
else
/*traverse q to find the prevous element adrs*/
while(temp!=*r)
{rleft=temp; temp=temp->link;}
/*delete the node*/
q=*r;item=q->data;
free(q);
*r=rleft;
(*r)->link=NULL;
/*if q becom empty after delet*/
if(*r==NULL)
*f=NULL;
return item;
}
/*to display**/
q_display(struct node *q)
{
printf("nfront->");
while(q!=NULL)
{
Page 2
S5-2
if(q->link==NULL)
printf("<-rear");
printf("%2d ",q->data);
q=q->link;
}
}
/*count nodes**/
count(struct node *q)
{
int c=0;
while(q!=NULL)
{
q=q->link; c++;}
return c;
}
Page 3

Más contenido relacionado

La actualidad más candente

La actualidad más candente (20)

Bcsl 033 data and file structures lab s3-1
Bcsl 033 data and file structures lab s3-1Bcsl 033 data and file structures lab s3-1
Bcsl 033 data and file structures lab s3-1
 
C Programming Example
C Programming ExampleC Programming Example
C Programming Example
 
Program for pyramid
Program for pyramidProgram for pyramid
Program for pyramid
 
week-1x
week-1xweek-1x
week-1x
 
C Programming Example
C Programming Example C Programming Example
C Programming Example
 
week-11x
week-11xweek-11x
week-11x
 
Insertion sort
Insertion sortInsertion sort
Insertion sort
 
week-10x
week-10xweek-10x
week-10x
 
C program to add two numbers
C program to add two numbers C program to add two numbers
C program to add two numbers
 
Ffffffffffff
FfffffffffffFfffffffffff
Ffffffffffff
 
Bcsl 033 data and file structures lab s3-2
Bcsl 033 data and file structures lab s3-2Bcsl 033 data and file structures lab s3-2
Bcsl 033 data and file structures lab s3-2
 
Bcsl 033 data and file structures lab s1-3
Bcsl 033 data and file structures lab s1-3Bcsl 033 data and file structures lab s1-3
Bcsl 033 data and file structures lab s1-3
 
C programs Set 2
C programs Set 2C programs Set 2
C programs Set 2
 
Bcsl 033 data and file structures lab s4-2
Bcsl 033 data and file structures lab s4-2Bcsl 033 data and file structures lab s4-2
Bcsl 033 data and file structures lab s4-2
 
week-4x
week-4xweek-4x
week-4x
 
Computer programing w
Computer programing wComputer programing w
Computer programing w
 
One dimensional operation of Array in C- language
One dimensional operation of Array in C- language One dimensional operation of Array in C- language
One dimensional operation of Array in C- language
 
C program to add n numbers
C program to add n numbers C program to add n numbers
C program to add n numbers
 
Shan
ShanShan
Shan
 
Add digits of number in c
Add digits of number in c Add digits of number in c
Add digits of number in c
 

Destacado

Kobie Quarterly Review: Retail Edition, June 2013
Kobie Quarterly Review: Retail Edition, June 2013Kobie Quarterly Review: Retail Edition, June 2013
Kobie Quarterly Review: Retail Edition, June 2013Jennifer Lingerfelt
 
Individual differences and call ppt
Individual differences and call pptIndividual differences and call ppt
Individual differences and call pptgianbisa
 
Yadira's 37th presentation
Yadira's 37th presentationYadira's 37th presentation
Yadira's 37th presentationDenis Martinez
 
Providing Access for Spanish Speaking Patrons
Providing Access for Spanish Speaking PatronsProviding Access for Spanish Speaking Patrons
Providing Access for Spanish Speaking Patronstomastoro
 
Who are SBS.doc
Who are SBS.docWho are SBS.doc
Who are SBS.docSally15
 
Justia and Amazon CloudSearch
Justia and Amazon CloudSearchJustia and Amazon CloudSearch
Justia and Amazon CloudSearchNick Moline
 
#ThroughGlass : An Introduction to Google Glass
#ThroughGlass : An Introduction to Google Glass#ThroughGlass : An Introduction to Google Glass
#ThroughGlass : An Introduction to Google GlassNick Moline
 
Individual differences and call ppt
Individual differences and call pptIndividual differences and call ppt
Individual differences and call pptgianbisa
 
Second Stage Booster: Optimizing Drupal and Wordpress for SEO, Speed and Soci...
Second Stage Booster: Optimizing Drupal and Wordpress for SEO, Speed and Soci...Second Stage Booster: Optimizing Drupal and Wordpress for SEO, Speed and Soci...
Second Stage Booster: Optimizing Drupal and Wordpress for SEO, Speed and Soci...Nick Moline
 
Sarcs sexii power point final
Sarcs sexii power point finalSarcs sexii power point final
Sarcs sexii power point finalMichael Greenwell
 
Clipacevedoslideshare 091126171514-phpapp01
Clipacevedoslideshare 091126171514-phpapp01Clipacevedoslideshare 091126171514-phpapp01
Clipacevedoslideshare 091126171514-phpapp01liveware82
 
まちづくりと復興について
まちづくりと復興についてまちづくりと復興について
まちづくりと復興についてJunichi Toyoshima
 
The story of_intenet_1
The story of_intenet_1The story of_intenet_1
The story of_intenet_1Jorgelcb
 
Who are SBS.doc
Who are SBS.docWho are SBS.doc
Who are SBS.docSally15
 

Destacado (20)

DJKrush
DJKrushDJKrush
DJKrush
 
Ning post 2
Ning post 2Ning post 2
Ning post 2
 
Kobie Quarterly Review: Retail Edition, June 2013
Kobie Quarterly Review: Retail Edition, June 2013Kobie Quarterly Review: Retail Edition, June 2013
Kobie Quarterly Review: Retail Edition, June 2013
 
Individual differences and call ppt
Individual differences and call pptIndividual differences and call ppt
Individual differences and call ppt
 
Ning post #4
Ning post #4Ning post #4
Ning post #4
 
Yadira's 37th presentation
Yadira's 37th presentationYadira's 37th presentation
Yadira's 37th presentation
 
Providing Access for Spanish Speaking Patrons
Providing Access for Spanish Speaking PatronsProviding Access for Spanish Speaking Patrons
Providing Access for Spanish Speaking Patrons
 
Who are SBS.doc
Who are SBS.docWho are SBS.doc
Who are SBS.doc
 
Justia and Amazon CloudSearch
Justia and Amazon CloudSearchJustia and Amazon CloudSearch
Justia and Amazon CloudSearch
 
#ThroughGlass : An Introduction to Google Glass
#ThroughGlass : An Introduction to Google Glass#ThroughGlass : An Introduction to Google Glass
#ThroughGlass : An Introduction to Google Glass
 
Moby
MobyMoby
Moby
 
Individual differences and call ppt
Individual differences and call pptIndividual differences and call ppt
Individual differences and call ppt
 
Second Stage Booster: Optimizing Drupal and Wordpress for SEO, Speed and Soci...
Second Stage Booster: Optimizing Drupal and Wordpress for SEO, Speed and Soci...Second Stage Booster: Optimizing Drupal and Wordpress for SEO, Speed and Soci...
Second Stage Booster: Optimizing Drupal and Wordpress for SEO, Speed and Soci...
 
Sarcs sexii power point final
Sarcs sexii power point finalSarcs sexii power point final
Sarcs sexii power point final
 
Ning post #3
Ning post #3Ning post #3
Ning post #3
 
Ning post #2
Ning post #2Ning post #2
Ning post #2
 
Clipacevedoslideshare 091126171514-phpapp01
Clipacevedoslideshare 091126171514-phpapp01Clipacevedoslideshare 091126171514-phpapp01
Clipacevedoslideshare 091126171514-phpapp01
 
まちづくりと復興について
まちづくりと復興についてまちづくりと復興について
まちづくりと復興について
 
The story of_intenet_1
The story of_intenet_1The story of_intenet_1
The story of_intenet_1
 
Who are SBS.doc
Who are SBS.docWho are SBS.doc
Who are SBS.doc
 

Similar a Bcsl 033 data and file structures lab s5-2

Computer Networks Lab File
Computer Networks Lab FileComputer Networks Lab File
Computer Networks Lab FileKandarp Tiwari
 
Graphic Design Lab File.docx
Graphic Design Lab File.docxGraphic Design Lab File.docx
Graphic Design Lab File.docxPayalJindal19
 
Building Hierarchy
Building HierarchyBuilding Hierarchy
Building HierarchyMohamed Samy
 
This code currently works... Run it and get a screen shot of its .docx
 This code currently works... Run it and get a screen shot of its .docx This code currently works... Run it and get a screen shot of its .docx
This code currently works... Run it and get a screen shot of its .docxKomlin1
 
Build 2016 - B880 - Top 6 Reasons to Move Your C++ Code to Visual Studio 2015
Build 2016 - B880 - Top 6 Reasons to Move Your C++ Code to Visual Studio 2015Build 2016 - B880 - Top 6 Reasons to Move Your C++ Code to Visual Studio 2015
Build 2016 - B880 - Top 6 Reasons to Move Your C++ Code to Visual Studio 2015Windows Developer
 
Compiler Construction | Lecture 2 | Declarative Syntax Definition
Compiler Construction | Lecture 2 | Declarative Syntax DefinitionCompiler Construction | Lecture 2 | Declarative Syntax Definition
Compiler Construction | Lecture 2 | Declarative Syntax DefinitionEelco Visser
 
20145-5SumII_CSC407_assign1.htmlCSC 407 Computer Systems II.docx
20145-5SumII_CSC407_assign1.htmlCSC 407 Computer Systems II.docx20145-5SumII_CSC407_assign1.htmlCSC 407 Computer Systems II.docx
20145-5SumII_CSC407_assign1.htmlCSC 407 Computer Systems II.docxeugeniadean34240
 
CS4200 2019 | Lecture 2 | syntax-definition
CS4200 2019 | Lecture 2 | syntax-definitionCS4200 2019 | Lecture 2 | syntax-definition
CS4200 2019 | Lecture 2 | syntax-definitionEelco Visser
 
Programming fundamentals
Programming fundamentalsProgramming fundamentals
Programming fundamentalsZaibi Gondal
 
Itp practical file_1-year
Itp practical file_1-yearItp practical file_1-year
Itp practical file_1-yearAMIT SINGH
 
'C' language notes (a.p)
'C' language notes (a.p)'C' language notes (a.p)
'C' language notes (a.p)Ashishchinu
 
Lab. Programs in C
Lab. Programs in CLab. Programs in C
Lab. Programs in CSaket Pathak
 
54602399 c-examples-51-to-108-programe-ee01083101
54602399 c-examples-51-to-108-programe-ee0108310154602399 c-examples-51-to-108-programe-ee01083101
54602399 c-examples-51-to-108-programe-ee01083101premrings
 
In C Programming create a program that converts a number from decimal.docx
In C Programming create a program that converts a number from decimal.docxIn C Programming create a program that converts a number from decimal.docx
In C Programming create a program that converts a number from decimal.docxtristans3
 

Similar a Bcsl 033 data and file structures lab s5-2 (20)

Data struture lab
Data struture labData struture lab
Data struture lab
 
Computer Networks Lab File
Computer Networks Lab FileComputer Networks Lab File
Computer Networks Lab File
 
Graphic Design Lab File.docx
Graphic Design Lab File.docxGraphic Design Lab File.docx
Graphic Design Lab File.docx
 
C++ manual Report Full
C++ manual Report FullC++ manual Report Full
C++ manual Report Full
 
Qt Workshop
Qt WorkshopQt Workshop
Qt Workshop
 
Building Hierarchy
Building HierarchyBuilding Hierarchy
Building Hierarchy
 
This code currently works... Run it and get a screen shot of its .docx
 This code currently works... Run it and get a screen shot of its .docx This code currently works... Run it and get a screen shot of its .docx
This code currently works... Run it and get a screen shot of its .docx
 
C program
C programC program
C program
 
Qe Reference
Qe ReferenceQe Reference
Qe Reference
 
Build 2016 - B880 - Top 6 Reasons to Move Your C++ Code to Visual Studio 2015
Build 2016 - B880 - Top 6 Reasons to Move Your C++ Code to Visual Studio 2015Build 2016 - B880 - Top 6 Reasons to Move Your C++ Code to Visual Studio 2015
Build 2016 - B880 - Top 6 Reasons to Move Your C++ Code to Visual Studio 2015
 
Compiler Construction | Lecture 2 | Declarative Syntax Definition
Compiler Construction | Lecture 2 | Declarative Syntax DefinitionCompiler Construction | Lecture 2 | Declarative Syntax Definition
Compiler Construction | Lecture 2 | Declarative Syntax Definition
 
20145-5SumII_CSC407_assign1.htmlCSC 407 Computer Systems II.docx
20145-5SumII_CSC407_assign1.htmlCSC 407 Computer Systems II.docx20145-5SumII_CSC407_assign1.htmlCSC 407 Computer Systems II.docx
20145-5SumII_CSC407_assign1.htmlCSC 407 Computer Systems II.docx
 
CS4200 2019 | Lecture 2 | syntax-definition
CS4200 2019 | Lecture 2 | syntax-definitionCS4200 2019 | Lecture 2 | syntax-definition
CS4200 2019 | Lecture 2 | syntax-definition
 
Programming fundamentals
Programming fundamentalsProgramming fundamentals
Programming fundamentals
 
Itp practical file_1-year
Itp practical file_1-yearItp practical file_1-year
Itp practical file_1-year
 
Muzzammilrashid
MuzzammilrashidMuzzammilrashid
Muzzammilrashid
 
'C' language notes (a.p)
'C' language notes (a.p)'C' language notes (a.p)
'C' language notes (a.p)
 
Lab. Programs in C
Lab. Programs in CLab. Programs in C
Lab. Programs in C
 
54602399 c-examples-51-to-108-programe-ee01083101
54602399 c-examples-51-to-108-programe-ee0108310154602399 c-examples-51-to-108-programe-ee01083101
54602399 c-examples-51-to-108-programe-ee01083101
 
In C Programming create a program that converts a number from decimal.docx
In C Programming create a program that converts a number from decimal.docxIn C Programming create a program that converts a number from decimal.docx
In C Programming create a program that converts a number from decimal.docx
 

Más de Dr. Loganathan R

Ch 6 IoT Processing Topologies and Types.pdf
Ch 6 IoT Processing Topologies and Types.pdfCh 6 IoT Processing Topologies and Types.pdf
Ch 6 IoT Processing Topologies and Types.pdfDr. Loganathan R
 
IoT Sensing and Actuation.pdf
 IoT Sensing and Actuation.pdf IoT Sensing and Actuation.pdf
IoT Sensing and Actuation.pdfDr. Loganathan R
 
Bcsl 033 data and file structures lab s4-3
Bcsl 033 data and file structures lab s4-3Bcsl 033 data and file structures lab s4-3
Bcsl 033 data and file structures lab s4-3Dr. Loganathan R
 
Bcsl 033 data and file structures lab s1-4
Bcsl 033 data and file structures lab s1-4Bcsl 033 data and file structures lab s1-4
Bcsl 033 data and file structures lab s1-4Dr. Loganathan R
 
Bcsl 033 data and file structures lab s1-2
Bcsl 033 data and file structures lab s1-2Bcsl 033 data and file structures lab s1-2
Bcsl 033 data and file structures lab s1-2Dr. Loganathan R
 
Introduction to Information Security
Introduction to Information SecurityIntroduction to Information Security
Introduction to Information SecurityDr. Loganathan R
 
Mcs 012 computer organisation and assemly language programming- ignou assignm...
Mcs 012 computer organisation and assemly language programming- ignou assignm...Mcs 012 computer organisation and assemly language programming- ignou assignm...
Mcs 012 computer organisation and assemly language programming- ignou assignm...Dr. Loganathan R
 
Session 9 4 alp to display the current system time using dos int 21 h
Session 9  4 alp to display the current system time using dos int 21 hSession 9  4 alp to display the current system time using dos int 21 h
Session 9 4 alp to display the current system time using dos int 21 hDr. Loganathan R
 
Session 9 1 alp to compute a grade using procedures
Session 9   1 alp to compute a grade using proceduresSession 9   1 alp to compute a grade using procedures
Session 9 1 alp to compute a grade using proceduresDr. Loganathan R
 
IGNOU Assembly Language Programming
IGNOU Assembly Language ProgrammingIGNOU Assembly Language Programming
IGNOU Assembly Language ProgrammingDr. Loganathan R
 
Requirement engineering process
Requirement engineering processRequirement engineering process
Requirement engineering processDr. Loganathan R
 
MCS 012 computer organisation and assembly language programming assignment…
MCS 012 computer organisation and assembly language programming assignment…MCS 012 computer organisation and assembly language programming assignment…
MCS 012 computer organisation and assembly language programming assignment…Dr. Loganathan R
 
Software engineering critical systems
Software engineering   critical systemsSoftware engineering   critical systems
Software engineering critical systemsDr. Loganathan R
 
Software engineering socio-technical systems
Software engineering   socio-technical systemsSoftware engineering   socio-technical systems
Software engineering socio-technical systemsDr. Loganathan R
 
Software engineering introduction
Software engineering   introductionSoftware engineering   introduction
Software engineering introductionDr. Loganathan R
 

Más de Dr. Loganathan R (18)

Ch 6 IoT Processing Topologies and Types.pdf
Ch 6 IoT Processing Topologies and Types.pdfCh 6 IoT Processing Topologies and Types.pdf
Ch 6 IoT Processing Topologies and Types.pdf
 
IoT Sensing and Actuation.pdf
 IoT Sensing and Actuation.pdf IoT Sensing and Actuation.pdf
IoT Sensing and Actuation.pdf
 
Ch 4 Emergence of IoT.pdf
Ch 4 Emergence of IoT.pdfCh 4 Emergence of IoT.pdf
Ch 4 Emergence of IoT.pdf
 
Bcsl 033 data and file structures lab s4-3
Bcsl 033 data and file structures lab s4-3Bcsl 033 data and file structures lab s4-3
Bcsl 033 data and file structures lab s4-3
 
Bcsl 033 data and file structures lab s1-4
Bcsl 033 data and file structures lab s1-4Bcsl 033 data and file structures lab s1-4
Bcsl 033 data and file structures lab s1-4
 
Bcsl 033 data and file structures lab s1-2
Bcsl 033 data and file structures lab s1-2Bcsl 033 data and file structures lab s1-2
Bcsl 033 data and file structures lab s1-2
 
Introduction to Information Security
Introduction to Information SecurityIntroduction to Information Security
Introduction to Information Security
 
Mcs 012 computer organisation and assemly language programming- ignou assignm...
Mcs 012 computer organisation and assemly language programming- ignou assignm...Mcs 012 computer organisation and assemly language programming- ignou assignm...
Mcs 012 computer organisation and assemly language programming- ignou assignm...
 
Session 9 4 alp to display the current system time using dos int 21 h
Session 9  4 alp to display the current system time using dos int 21 hSession 9  4 alp to display the current system time using dos int 21 h
Session 9 4 alp to display the current system time using dos int 21 h
 
Session 9 1 alp to compute a grade using procedures
Session 9   1 alp to compute a grade using proceduresSession 9   1 alp to compute a grade using procedures
Session 9 1 alp to compute a grade using procedures
 
IGNOU Assembly Language Programming
IGNOU Assembly Language ProgrammingIGNOU Assembly Language Programming
IGNOU Assembly Language Programming
 
Requirement engineering process
Requirement engineering processRequirement engineering process
Requirement engineering process
 
MCS 012 computer organisation and assembly language programming assignment…
MCS 012 computer organisation and assembly language programming assignment…MCS 012 computer organisation and assembly language programming assignment…
MCS 012 computer organisation and assembly language programming assignment…
 
Software requirements
Software requirementsSoftware requirements
Software requirements
 
Software process
Software processSoftware process
Software process
 
Software engineering critical systems
Software engineering   critical systemsSoftware engineering   critical systems
Software engineering critical systems
 
Software engineering socio-technical systems
Software engineering   socio-technical systemsSoftware engineering   socio-technical systems
Software engineering socio-technical systems
 
Software engineering introduction
Software engineering   introductionSoftware engineering   introduction
Software engineering introduction
 

Último

Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17Celine George
 
Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.MateoGardella
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingTeacherCyreneCayanan
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxnegromaestrong
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfChris Hunter
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhikauryashika82
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxVishalSingh1417
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docxPoojaSen20
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docxPoojaSen20
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 

Último (20)

Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 

Bcsl 033 data and file structures lab s5-2

  • 1. S5-2 Write a program in ‘C’ language to implement a Dequeue using pointers. All operations associated with a Dequeue are to be implemented. #include<stdio.h> #include<conio.h> struct node { int data; struct node *link;}; void addqatend(struct node**,struct node**,int); void addqatbeg(struct node**,struct node**,int); delqatbeg(struct node**,struct node**); delqatend(struct node**,struct node**); main() { struct node*front,*rear; int item; front=rear=NULL; addqatend(&front,&rear,11); addqatend(&front,&rear,81); addqatend(&front,&rear,16); addqatend(&front,&rear,45); addqatbeg(&front,&rear,20); clrscr(); q_display(front); printf("nnumber of elements in the que=%d",count(front)); printf("nitems taken from qn"); item=delqatbeg(&front,&rear); printf("%d ",item); printf("nafter deletionn"); q_display(front); getch(); } /*adds a new element at end **/ void addqatend(struct node **f,struct node **r,int item) { struct node *q; q=(struct node*)malloc(sizeof(struct node)); q->data=item; q->link=NULL; /**if q empty**/ if(*f==NULL) *f=q; else (*r)->link=q; *r=q; } /*add at begin**/ void addqatbeg(struct node** f,struct node** r,int item) { struct node *q; int t; Page 1
  • 2. S5-2 q=(struct node*)malloc(sizeof(struct node)); q->data=item; q->link=NULL; /**if q empty**/ if(*f==NULL) *f=*r=q; else q->link=*f; *r=*f; *f=q; } /*remove from front ***/ delqatbeg(struct node** f,struct node** r) { struct node *q; int item; if(*f==NULL) printf("q empty"); else q=*f;item=q->data; *f=q->link; free(q); /*if q becom empty after delet*/ if(*f==NULL) *r=NULL; return item; } /*remove from rear end ***/ delqatend(struct node** f,struct node** r) { struct node *q,*rleft,*temp; int item; temp=*f; if(*r==NULL) printf("q empty"); else /*traverse q to find the prevous element adrs*/ while(temp!=*r) {rleft=temp; temp=temp->link;} /*delete the node*/ q=*r;item=q->data; free(q); *r=rleft; (*r)->link=NULL; /*if q becom empty after delet*/ if(*r==NULL) *f=NULL; return item; } /*to display**/ q_display(struct node *q) { printf("nfront->"); while(q!=NULL) { Page 2
  • 3. S5-2 if(q->link==NULL) printf("<-rear"); printf("%2d ",q->data); q=q->link; } } /*count nodes**/ count(struct node *q) { int c=0; while(q!=NULL) { q=q->link; c++;} return c; } Page 3