SlideShare a Scribd company logo
1 of 2
Download to read offline
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.docxacarolyn
 
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
 
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.pdfanupambedcovers
 
Link list part 2
Link list part 2Link list part 2
Link list part 2Anaya Zafar
 
#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.pdflakshmijewellery
 
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.pdffacevenky
 
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 Diplomamustkeem 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 structuresLakshmi 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 structureZarghamullahShah
 
data structure3.pptx
data structure3.pptxdata structure3.pptx
data structure3.pptxSajalFayyaz
 
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.docxgerardkortney
 
Data Structures Lab 8.pptx
Data Structures Lab 8.pptxData Structures Lab 8.pptx
Data Structures Lab 8.pptxmervat32
 

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
 
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
 
Lab-2.2 717822E504.pdf
Lab-2.2 717822E504.pdfLab-2.2 717822E504.pdf
Lab-2.2 717822E504.pdf
 

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.pdfarjuncp10
 
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.pdfarjuncp10
 
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.pdfarjuncp10
 
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 .pdfarjuncp10
 
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.pdfarjuncp10
 
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.pdfarjuncp10
 
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.pdfarjuncp10
 
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.pdfarjuncp10
 
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.pdfarjuncp10
 
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.pdfarjuncp10
 
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.pdfarjuncp10
 
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.pdfarjuncp10
 
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 _.pdfarjuncp10
 
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.pdfarjuncp10
 
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 .pdfarjuncp10
 
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.pdfarjuncp10
 
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.pdfarjuncp10
 
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 .pdfarjuncp10
 
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.pdfarjuncp10
 
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.pdfarjuncp10
 

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

Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxJisc
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxheathfieldcps1
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxannathomasp01
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxEsquimalt MFRC
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxDr. Sarita Anand
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxmarlenawright1
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jisc
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsMebane Rash
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Pooja Bhuva
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...ZurliaSoop
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxCeline George
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Jisc
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsKarakKing
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...Nguyen Thanh Tu Collection
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the ClassroomPooky Knightsmith
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptxMaritesTamaniVerdade
 
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
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxPooja Bhuva
 

Recently uploaded (20)

Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
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
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
 

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; }