SlideShare a Scribd company logo
C++
Write a function void headEnqueue(Queue *q, int key) which enqueues the key such that, at
function exit, it is positioned at the head of the queue rather than the tail; and the order and
integrity of the queue is otherwise maintained.
Solution
struct node
{
int data;
node* next;
};
class Queue //linked_list class
{
private:
node* front;
node* rear;
public:
Queue();
void insert(int);
headEnqueue(Queue *q, int key);
};
Queue::Queue()
{
front = rear = NULL;
}
void Queue::insert(int val)
{
node* temp = new node;
temp->data = val;
temp->next = NULL;
if (front == NULL)
front= rear = temp;
else {
node* temp1 = front;
while (temp1->next)
temp1 = temp1->next;
temp1->next = temp;
}
}
void Queue::headEnqueue(Queue *q, int key)
{
node* temp = new node;
temp->data = key;
temp->next=q->front;
q->front=temp;
}

More Related Content

Similar to C++Write a function void headEnqueue(Queue q, int key) which enqu.pdf

reverse the linked list (2-4-8-10) by- stack- iteration- recursion- U.docx
reverse the linked list (2-4-8-10) by- stack- iteration- recursion-  U.docxreverse the linked list (2-4-8-10) by- stack- iteration- recursion-  U.docx
reverse the linked list (2-4-8-10) by- stack- iteration- recursion- U.docx
acarolyn
 
DATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDY
DATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDYDATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDY
DATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDYMalikireddy Bramhananda Reddy
 
DSA(1).pptx
DSA(1).pptxDSA(1).pptx
DSA(1).pptx
DaniyalAli81
 
Data Structures and Agorithm: DS 09 Queue.pptx
Data Structures and Agorithm: DS 09 Queue.pptxData Structures and Agorithm: DS 09 Queue.pptx
Data Structures and Agorithm: DS 09 Queue.pptx
RashidFaridChishti
 
C++ Program to Implement Singly Linked List #includei.pdf
  C++ Program to Implement Singly Linked List  #includei.pdf  C++ Program to Implement Singly Linked List  #includei.pdf
C++ Program to Implement Singly Linked List #includei.pdf
anupambedcovers
 
Link list part 2
Link list part 2Link list part 2
Link list part 2
Anaya Zafar
 
Linked list
Linked listLinked list
Linked list
akshat360
 
#include iostream #includestdlib.h using namespace std;str.pdf
#include iostream #includestdlib.h using namespace std;str.pdf#include iostream #includestdlib.h using namespace std;str.pdf
#include iostream #includestdlib.h using namespace std;str.pdf
lakshmijewellery
 
double linked list header file code#include iostream#include.pdf
double linked list header file code#include iostream#include.pdfdouble linked list header file code#include iostream#include.pdf
double linked list header file code#include iostream#include.pdf
facevenky
 
DATA STRUCTURE USING C & C++
DATA STRUCTURE USING C & C++DATA STRUCTURE USING C & C++
DATA STRUCTURE USING C & C++
mustkeem khan
 
DSU C&C++ Practical File Diploma
DSU C&C++ Practical File DiplomaDSU C&C++ Practical File Diploma
DSU C&C++ Practical File Diploma
mustkeem khan
 
Solutionsfor co2 C Programs for data structures
Solutionsfor co2 C Programs for data structuresSolutionsfor co2 C Programs for data structures
Solutionsfor co2 C Programs for data structures
Lakshmi Sarvani Videla
 
Binary Tree in C++ coding in the data structure
Binary Tree in C++ coding in the data structureBinary Tree in C++ coding in the data structure
Binary Tree in C++ coding in the data structure
ZarghamullahShah
 
data structure3.pptx
data structure3.pptxdata structure3.pptx
data structure3.pptx
SajalFayyaz
 
Linked lists
Linked listsLinked lists
Linked lists
George Scott IV
 
package algs13;import stdlib.;import java.util.Iterator;im.docx
package algs13;import  stdlib.;import java.util.Iterator;im.docxpackage algs13;import  stdlib.;import java.util.Iterator;im.docx
package algs13;import stdlib.;import java.util.Iterator;im.docx
gerardkortney
 
Dsprograms(2nd cse)
Dsprograms(2nd cse)Dsprograms(2nd cse)
Dsprograms(2nd cse)
Pradeep Kumar Reddy Reddy
 
Data Structures Lab 8.pptx
Data Structures Lab 8.pptxData Structures Lab 8.pptx
Data Structures Lab 8.pptx
mervat32
 

Similar to C++Write a function void headEnqueue(Queue q, int key) which enqu.pdf (20)

137 Lab-2.2.pdf
137 Lab-2.2.pdf137 Lab-2.2.pdf
137 Lab-2.2.pdf
 
reverse the linked list (2-4-8-10) by- stack- iteration- recursion- U.docx
reverse the linked list (2-4-8-10) by- stack- iteration- recursion-  U.docxreverse the linked list (2-4-8-10) by- stack- iteration- recursion-  U.docx
reverse the linked list (2-4-8-10) by- stack- iteration- recursion- U.docx
 
DATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDY
DATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDYDATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDY
DATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDY
 
DSA(1).pptx
DSA(1).pptxDSA(1).pptx
DSA(1).pptx
 
Data Structures and Agorithm: DS 09 Queue.pptx
Data Structures and Agorithm: DS 09 Queue.pptxData Structures and Agorithm: DS 09 Queue.pptx
Data Structures and Agorithm: DS 09 Queue.pptx
 
C++ Program to Implement Singly Linked List #includei.pdf
  C++ Program to Implement Singly Linked List  #includei.pdf  C++ Program to Implement Singly Linked List  #includei.pdf
C++ Program to Implement Singly Linked List #includei.pdf
 
Link list part 2
Link list part 2Link list part 2
Link list part 2
 
Linked list
Linked listLinked list
Linked list
 
Queue oop
Queue   oopQueue   oop
Queue oop
 
#include iostream #includestdlib.h using namespace std;str.pdf
#include iostream #includestdlib.h using namespace std;str.pdf#include iostream #includestdlib.h using namespace std;str.pdf
#include iostream #includestdlib.h using namespace std;str.pdf
 
double linked list header file code#include iostream#include.pdf
double linked list header file code#include iostream#include.pdfdouble linked list header file code#include iostream#include.pdf
double linked list header file code#include iostream#include.pdf
 
DATA STRUCTURE USING C & C++
DATA STRUCTURE USING C & C++DATA STRUCTURE USING C & C++
DATA STRUCTURE USING C & C++
 
DSU C&C++ Practical File Diploma
DSU C&C++ Practical File DiplomaDSU C&C++ Practical File Diploma
DSU C&C++ Practical File Diploma
 
Solutionsfor co2 C Programs for data structures
Solutionsfor co2 C Programs for data structuresSolutionsfor co2 C Programs for data structures
Solutionsfor co2 C Programs for data structures
 
Binary Tree in C++ coding in the data structure
Binary Tree in C++ coding in the data structureBinary Tree in C++ coding in the data structure
Binary Tree in C++ coding in the data structure
 
data structure3.pptx
data structure3.pptxdata structure3.pptx
data structure3.pptx
 
Linked lists
Linked listsLinked lists
Linked lists
 
package algs13;import stdlib.;import java.util.Iterator;im.docx
package algs13;import  stdlib.;import java.util.Iterator;im.docxpackage algs13;import  stdlib.;import java.util.Iterator;im.docx
package algs13;import stdlib.;import java.util.Iterator;im.docx
 
Dsprograms(2nd cse)
Dsprograms(2nd cse)Dsprograms(2nd cse)
Dsprograms(2nd cse)
 
Data Structures Lab 8.pptx
Data Structures Lab 8.pptxData Structures Lab 8.pptx
Data Structures Lab 8.pptx
 

More from arjuncp10

I l Show that if X has the discrete topology, then its only conn.pdf
I l Show that if X has the discrete topology, then its only conn.pdfI l Show that if X has the discrete topology, then its only conn.pdf
I l Show that if X has the discrete topology, then its only conn.pdf
arjuncp10
 
In 2006 the CEO of Bear Sterns, James Caynes, received a compensatio.pdf
In 2006 the CEO of Bear Sterns, James Caynes, received a compensatio.pdfIn 2006 the CEO of Bear Sterns, James Caynes, received a compensatio.pdf
In 2006 the CEO of Bear Sterns, James Caynes, received a compensatio.pdf
arjuncp10
 
How would a CFE devise a plan to prevent subsequent employee fraud.pdf
How would a CFE devise a plan to prevent subsequent employee fraud.pdfHow would a CFE devise a plan to prevent subsequent employee fraud.pdf
How would a CFE devise a plan to prevent subsequent employee fraud.pdf
arjuncp10
 
Hilary rode her horse for 8 miles until it was hurt.Then she walked .pdf
Hilary rode her horse for 8 miles until it was hurt.Then she walked .pdfHilary rode her horse for 8 miles until it was hurt.Then she walked .pdf
Hilary rode her horse for 8 miles until it was hurt.Then she walked .pdf
arjuncp10
 
fully comments for my program, thank you will thumb up#include io.pdf
fully comments for my program, thank you will thumb up#include io.pdffully comments for my program, thank you will thumb up#include io.pdf
fully comments for my program, thank you will thumb up#include io.pdf
arjuncp10
 
Find the admittance Yab in the circuit seen in the figure. Take that.pdf
Find the admittance Yab in the circuit seen in the figure. Take that.pdfFind the admittance Yab in the circuit seen in the figure. Take that.pdf
Find the admittance Yab in the circuit seen in the figure. Take that.pdf
arjuncp10
 
Diversity Paper Each student will complete a diversity research assig.pdf
Diversity Paper Each student will complete a diversity research assig.pdfDiversity Paper Each student will complete a diversity research assig.pdf
Diversity Paper Each student will complete a diversity research assig.pdf
arjuncp10
 
Detailed solutions please 1. Let R and S be commutative rings and le.pdf
Detailed solutions please 1. Let R and S be commutative rings and le.pdfDetailed solutions please 1. Let R and S be commutative rings and le.pdf
Detailed solutions please 1. Let R and S be commutative rings and le.pdf
arjuncp10
 
Describe the mechanisms of asexual reproduction inProkaryotesPr.pdf
Describe the mechanisms of asexual reproduction inProkaryotesPr.pdfDescribe the mechanisms of asexual reproduction inProkaryotesPr.pdf
Describe the mechanisms of asexual reproduction inProkaryotesPr.pdf
arjuncp10
 
Define intermediate phenotype and then imagine some intermediate phe.pdf
Define intermediate phenotype and then imagine some intermediate phe.pdfDefine intermediate phenotype and then imagine some intermediate phe.pdf
Define intermediate phenotype and then imagine some intermediate phe.pdf
arjuncp10
 
Consider a population of lizards living on the coast of Africa. A sto.pdf
Consider a population of lizards living on the coast of Africa. A sto.pdfConsider a population of lizards living on the coast of Africa. A sto.pdf
Consider a population of lizards living on the coast of Africa. A sto.pdf
arjuncp10
 
Can “discovery science” (for example, the discovery of a new species.pdf
Can “discovery science” (for example, the discovery of a new species.pdfCan “discovery science” (for example, the discovery of a new species.pdf
Can “discovery science” (for example, the discovery of a new species.pdf
arjuncp10
 
All of the following are features or functions of nanobodies except _.pdf
All of the following are features or functions of nanobodies except _.pdfAll of the following are features or functions of nanobodies except _.pdf
All of the following are features or functions of nanobodies except _.pdf
arjuncp10
 
A girl running at a constant speed of 1.4ms in a straight line thro.pdf
A girl running at a constant speed of 1.4ms in a straight line thro.pdfA girl running at a constant speed of 1.4ms in a straight line thro.pdf
A girl running at a constant speed of 1.4ms in a straight line thro.pdf
arjuncp10
 
You have a rural dial-up customer who complains that a large number .pdf
You have a rural dial-up customer who complains that a large number .pdfYou have a rural dial-up customer who complains that a large number .pdf
You have a rural dial-up customer who complains that a large number .pdf
arjuncp10
 
You are given a mixed culture containing a anaerobic thermophile, ae.pdf
You are given a mixed culture containing a anaerobic thermophile, ae.pdfYou are given a mixed culture containing a anaerobic thermophile, ae.pdf
You are given a mixed culture containing a anaerobic thermophile, ae.pdf
arjuncp10
 
Woyld removing phenylethyl alcohol from PEA alter the mediumsS.pdf
Woyld removing phenylethyl alcohol from PEA alter the mediumsS.pdfWoyld removing phenylethyl alcohol from PEA alter the mediumsS.pdf
Woyld removing phenylethyl alcohol from PEA alter the mediumsS.pdf
arjuncp10
 
Which abstraction uses slates, state transitions, inputs and outputs .pdf
Which abstraction uses slates, state transitions, inputs and outputs .pdfWhich abstraction uses slates, state transitions, inputs and outputs .pdf
Which abstraction uses slates, state transitions, inputs and outputs .pdf
arjuncp10
 
What is the target cell for the hormone AngiotensionogenSolut.pdf
What is the target cell for the hormone AngiotensionogenSolut.pdfWhat is the target cell for the hormone AngiotensionogenSolut.pdf
What is the target cell for the hormone AngiotensionogenSolut.pdf
arjuncp10
 
What is a possible evolutionary advantage of having intronsexons in.pdf
What is a possible evolutionary advantage of having intronsexons in.pdfWhat is a possible evolutionary advantage of having intronsexons in.pdf
What is a possible evolutionary advantage of having intronsexons in.pdf
arjuncp10
 

More from arjuncp10 (20)

I l Show that if X has the discrete topology, then its only conn.pdf
I l Show that if X has the discrete topology, then its only conn.pdfI l Show that if X has the discrete topology, then its only conn.pdf
I l Show that if X has the discrete topology, then its only conn.pdf
 
In 2006 the CEO of Bear Sterns, James Caynes, received a compensatio.pdf
In 2006 the CEO of Bear Sterns, James Caynes, received a compensatio.pdfIn 2006 the CEO of Bear Sterns, James Caynes, received a compensatio.pdf
In 2006 the CEO of Bear Sterns, James Caynes, received a compensatio.pdf
 
How would a CFE devise a plan to prevent subsequent employee fraud.pdf
How would a CFE devise a plan to prevent subsequent employee fraud.pdfHow would a CFE devise a plan to prevent subsequent employee fraud.pdf
How would a CFE devise a plan to prevent subsequent employee fraud.pdf
 
Hilary rode her horse for 8 miles until it was hurt.Then she walked .pdf
Hilary rode her horse for 8 miles until it was hurt.Then she walked .pdfHilary rode her horse for 8 miles until it was hurt.Then she walked .pdf
Hilary rode her horse for 8 miles until it was hurt.Then she walked .pdf
 
fully comments for my program, thank you will thumb up#include io.pdf
fully comments for my program, thank you will thumb up#include io.pdffully comments for my program, thank you will thumb up#include io.pdf
fully comments for my program, thank you will thumb up#include io.pdf
 
Find the admittance Yab in the circuit seen in the figure. Take that.pdf
Find the admittance Yab in the circuit seen in the figure. Take that.pdfFind the admittance Yab in the circuit seen in the figure. Take that.pdf
Find the admittance Yab in the circuit seen in the figure. Take that.pdf
 
Diversity Paper Each student will complete a diversity research assig.pdf
Diversity Paper Each student will complete a diversity research assig.pdfDiversity Paper Each student will complete a diversity research assig.pdf
Diversity Paper Each student will complete a diversity research assig.pdf
 
Detailed solutions please 1. Let R and S be commutative rings and le.pdf
Detailed solutions please 1. Let R and S be commutative rings and le.pdfDetailed solutions please 1. Let R and S be commutative rings and le.pdf
Detailed solutions please 1. Let R and S be commutative rings and le.pdf
 
Describe the mechanisms of asexual reproduction inProkaryotesPr.pdf
Describe the mechanisms of asexual reproduction inProkaryotesPr.pdfDescribe the mechanisms of asexual reproduction inProkaryotesPr.pdf
Describe the mechanisms of asexual reproduction inProkaryotesPr.pdf
 
Define intermediate phenotype and then imagine some intermediate phe.pdf
Define intermediate phenotype and then imagine some intermediate phe.pdfDefine intermediate phenotype and then imagine some intermediate phe.pdf
Define intermediate phenotype and then imagine some intermediate phe.pdf
 
Consider a population of lizards living on the coast of Africa. A sto.pdf
Consider a population of lizards living on the coast of Africa. A sto.pdfConsider a population of lizards living on the coast of Africa. A sto.pdf
Consider a population of lizards living on the coast of Africa. A sto.pdf
 
Can “discovery science” (for example, the discovery of a new species.pdf
Can “discovery science” (for example, the discovery of a new species.pdfCan “discovery science” (for example, the discovery of a new species.pdf
Can “discovery science” (for example, the discovery of a new species.pdf
 
All of the following are features or functions of nanobodies except _.pdf
All of the following are features or functions of nanobodies except _.pdfAll of the following are features or functions of nanobodies except _.pdf
All of the following are features or functions of nanobodies except _.pdf
 
A girl running at a constant speed of 1.4ms in a straight line thro.pdf
A girl running at a constant speed of 1.4ms in a straight line thro.pdfA girl running at a constant speed of 1.4ms in a straight line thro.pdf
A girl running at a constant speed of 1.4ms in a straight line thro.pdf
 
You have a rural dial-up customer who complains that a large number .pdf
You have a rural dial-up customer who complains that a large number .pdfYou have a rural dial-up customer who complains that a large number .pdf
You have a rural dial-up customer who complains that a large number .pdf
 
You are given a mixed culture containing a anaerobic thermophile, ae.pdf
You are given a mixed culture containing a anaerobic thermophile, ae.pdfYou are given a mixed culture containing a anaerobic thermophile, ae.pdf
You are given a mixed culture containing a anaerobic thermophile, ae.pdf
 
Woyld removing phenylethyl alcohol from PEA alter the mediumsS.pdf
Woyld removing phenylethyl alcohol from PEA alter the mediumsS.pdfWoyld removing phenylethyl alcohol from PEA alter the mediumsS.pdf
Woyld removing phenylethyl alcohol from PEA alter the mediumsS.pdf
 
Which abstraction uses slates, state transitions, inputs and outputs .pdf
Which abstraction uses slates, state transitions, inputs and outputs .pdfWhich abstraction uses slates, state transitions, inputs and outputs .pdf
Which abstraction uses slates, state transitions, inputs and outputs .pdf
 
What is the target cell for the hormone AngiotensionogenSolut.pdf
What is the target cell for the hormone AngiotensionogenSolut.pdfWhat is the target cell for the hormone AngiotensionogenSolut.pdf
What is the target cell for the hormone AngiotensionogenSolut.pdf
 
What is a possible evolutionary advantage of having intronsexons in.pdf
What is a possible evolutionary advantage of having intronsexons in.pdfWhat is a possible evolutionary advantage of having intronsexons in.pdf
What is a possible evolutionary advantage of having intronsexons in.pdf
 

Recently uploaded

Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
Atul Kumar Singh
 
Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)
rosedainty
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
bennyroshan06
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
TechSoup
 
Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumers
PedroFerreira53928
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
joachimlavalley1
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
EugeneSaldivar
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
PedroFerreira53928
 
How to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPHow to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERP
Celine George
 
Introduction to Quality Improvement Essentials
Introduction to Quality Improvement EssentialsIntroduction to Quality Improvement Essentials
Introduction to Quality Improvement Essentials
Excellence Foundation for South Sudan
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
Balvir Singh
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
The Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonThe Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve Thomason
Steve Thomason
 
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdfESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
Fundacja Rozwoju Społeczeństwa Przedsiębiorczego
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
Tamralipta Mahavidyalaya
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
RaedMohamed3
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
AzmatAli747758
 

Recently uploaded (20)

Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
 
Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
 
Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumers
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
 
How to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPHow to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERP
 
Introduction to Quality Improvement Essentials
Introduction to Quality Improvement EssentialsIntroduction to Quality Improvement Essentials
Introduction to Quality Improvement Essentials
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
The Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonThe Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve Thomason
 
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdfESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
 

C++Write a function void headEnqueue(Queue q, int key) which enqu.pdf

  • 1. C++ Write a function void headEnqueue(Queue *q, int key) which enqueues the key such that, at function exit, it is positioned at the head of the queue rather than the tail; and the order and integrity of the queue is otherwise maintained. Solution struct node { int data; node* next; }; class Queue //linked_list class { private: node* front; node* rear; public: Queue(); void insert(int); headEnqueue(Queue *q, int key); }; Queue::Queue() { front = rear = NULL; } void Queue::insert(int val) { node* temp = new node; temp->data = val; temp->next = NULL; if (front == NULL) front= rear = temp;
  • 2. else { node* temp1 = front; while (temp1->next) temp1 = temp1->next; temp1->next = temp; } } void Queue::headEnqueue(Queue *q, int key) { node* temp = new node; temp->data = key; temp->next=q->front; q->front=temp; }