SlideShare a Scribd company logo
1 of 1
Download to read offline
C++ Program:
N-number queue rotations.
[16] Write methods void Queue::lRotate(int n) and void Queue::rRotate(int n) which rotate the
queue by n-number elements.
Solution
void rRotate(int& root){
item* tmpRoot = itemArray[root];
int ogLeft = tmpRoot->left;
tmpRoot->left = itemArray[ogLeft]->right;
itemArray[ogLeft]->right = root;
root = ogLeft; //to be made the (sub)root outside the method
}
void lRotate(int& root){
item* tmpRoot = itemArray[root];
int ogRight = tmpRoot->right;
tmpRoot->right = itemArray[ogRight]->left;
itemArray[ogRight]->left = root;
root = ogRight; //to be made the (sub)root outside the method
}

More Related Content

More from gopalk44

how are the technological approaches of cloning and IPSCs similar to.pdf
how are the technological approaches of cloning and IPSCs similar to.pdfhow are the technological approaches of cloning and IPSCs similar to.pdf
how are the technological approaches of cloning and IPSCs similar to.pdf
gopalk44
 
Discuss the various types of business crimes, a business liability f.pdf
Discuss the various types of business crimes, a business liability f.pdfDiscuss the various types of business crimes, a business liability f.pdf
Discuss the various types of business crimes, a business liability f.pdf
gopalk44
 
Describe the different types of ribs. Which ribs are considered “fal.pdf
Describe the different types of ribs. Which ribs are considered “fal.pdfDescribe the different types of ribs. Which ribs are considered “fal.pdf
Describe the different types of ribs. Which ribs are considered “fal.pdf
gopalk44
 
Circle the best answer to the following questions. From the Bohr mod.pdf
Circle the best answer to the following questions.  From the Bohr mod.pdfCircle the best answer to the following questions.  From the Bohr mod.pdf
Circle the best answer to the following questions. From the Bohr mod.pdf
gopalk44
 
Below are two possible tree topologies. How many clades are different.pdf
Below are two possible tree topologies. How many clades are different.pdfBelow are two possible tree topologies. How many clades are different.pdf
Below are two possible tree topologies. How many clades are different.pdf
gopalk44
 
WriteBelow are a list of descriptions that apply to either post s.pdf
WriteBelow are a list of descriptions that apply to either post s.pdfWriteBelow are a list of descriptions that apply to either post s.pdf
WriteBelow are a list of descriptions that apply to either post s.pdf
gopalk44
 
Write the letter(s) of answers to the questions below. I. ksentify th.pdf
Write the letter(s) of answers to the questions below. I. ksentify th.pdfWrite the letter(s) of answers to the questions below. I. ksentify th.pdf
Write the letter(s) of answers to the questions below. I. ksentify th.pdf
gopalk44
 
Why following sort does not work (It does not sort last 2 - 3 numbe.pdf
Why following sort does not work (It does not sort last 2 - 3 numbe.pdfWhy following sort does not work (It does not sort last 2 - 3 numbe.pdf
Why following sort does not work (It does not sort last 2 - 3 numbe.pdf
gopalk44
 
Within the Discussion Board area, write 400-600 words that respond to.pdf
Within the Discussion Board area, write 400-600 words that respond to.pdfWithin the Discussion Board area, write 400-600 words that respond to.pdf
Within the Discussion Board area, write 400-600 words that respond to.pdf
gopalk44
 

More from gopalk44 (20)

how many chromosomes will be found in each cell at the end of anapha.pdf
how many chromosomes will be found in each cell at the end of anapha.pdfhow many chromosomes will be found in each cell at the end of anapha.pdf
how many chromosomes will be found in each cell at the end of anapha.pdf
 
how are the technological approaches of cloning and IPSCs similar to.pdf
how are the technological approaches of cloning and IPSCs similar to.pdfhow are the technological approaches of cloning and IPSCs similar to.pdf
how are the technological approaches of cloning and IPSCs similar to.pdf
 
HELP! Thought I can figure this one out but got it wrong. I have one.pdf
HELP! Thought I can figure this one out but got it wrong. I have one.pdfHELP! Thought I can figure this one out but got it wrong. I have one.pdf
HELP! Thought I can figure this one out but got it wrong. I have one.pdf
 
From a recent statistical analysis for the last five years, on an av.pdf
From a recent statistical analysis for the last five years, on an av.pdfFrom a recent statistical analysis for the last five years, on an av.pdf
From a recent statistical analysis for the last five years, on an av.pdf
 
Find asymptotic upperlower bounds. Find asymptotic upperlower boun.pdf
Find asymptotic upperlower bounds. Find asymptotic upperlower boun.pdfFind asymptotic upperlower bounds. Find asymptotic upperlower boun.pdf
Find asymptotic upperlower bounds. Find asymptotic upperlower boun.pdf
 
Explain how a wireless device can help an organization perform busin.pdf
Explain how a wireless device can help an organization perform busin.pdfExplain how a wireless device can help an organization perform busin.pdf
Explain how a wireless device can help an organization perform busin.pdf
 
Exam scores were normal in BIO 200. Jasons exam score was one stan.pdf
Exam scores were normal in BIO 200. Jasons exam score was one stan.pdfExam scores were normal in BIO 200. Jasons exam score was one stan.pdf
Exam scores were normal in BIO 200. Jasons exam score was one stan.pdf
 
Discuss the various types of business crimes, a business liability f.pdf
Discuss the various types of business crimes, a business liability f.pdfDiscuss the various types of business crimes, a business liability f.pdf
Discuss the various types of business crimes, a business liability f.pdf
 
Describe the different types of ribs. Which ribs are considered “fal.pdf
Describe the different types of ribs. Which ribs are considered “fal.pdfDescribe the different types of ribs. Which ribs are considered “fal.pdf
Describe the different types of ribs. Which ribs are considered “fal.pdf
 
Circle the best answer to the following questions. From the Bohr mod.pdf
Circle the best answer to the following questions.  From the Bohr mod.pdfCircle the best answer to the following questions.  From the Bohr mod.pdf
Circle the best answer to the following questions. From the Bohr mod.pdf
 
Below are two possible tree topologies. How many clades are different.pdf
Below are two possible tree topologies. How many clades are different.pdfBelow are two possible tree topologies. How many clades are different.pdf
Below are two possible tree topologies. How many clades are different.pdf
 
WriteBelow are a list of descriptions that apply to either post s.pdf
WriteBelow are a list of descriptions that apply to either post s.pdfWriteBelow are a list of descriptions that apply to either post s.pdf
WriteBelow are a list of descriptions that apply to either post s.pdf
 
Write the letter(s) of answers to the questions below. I. ksentify th.pdf
Write the letter(s) of answers to the questions below. I. ksentify th.pdfWrite the letter(s) of answers to the questions below. I. ksentify th.pdf
Write the letter(s) of answers to the questions below. I. ksentify th.pdf
 
Write Assembly code (8086) that implements the function of (A.B) +C..pdf
Write Assembly code (8086) that implements the function of (A.B) +C..pdfWrite Assembly code (8086) that implements the function of (A.B) +C..pdf
Write Assembly code (8086) that implements the function of (A.B) +C..pdf
 
Who was Floyd Allport and what are his main achievementsWho was.pdf
Who was Floyd Allport and what are his main achievementsWho was.pdfWho was Floyd Allport and what are his main achievementsWho was.pdf
Who was Floyd Allport and what are his main achievementsWho was.pdf
 
Why following sort does not work (It does not sort last 2 - 3 numbe.pdf
Why following sort does not work (It does not sort last 2 - 3 numbe.pdfWhy following sort does not work (It does not sort last 2 - 3 numbe.pdf
Why following sort does not work (It does not sort last 2 - 3 numbe.pdf
 
Within the Discussion Board area, write 400-600 words that respond to.pdf
Within the Discussion Board area, write 400-600 words that respond to.pdfWithin the Discussion Board area, write 400-600 words that respond to.pdf
Within the Discussion Board area, write 400-600 words that respond to.pdf
 
Which statement is true with regards to acetylation of histones Dea.pdf
Which statement is true with regards to acetylation of histones  Dea.pdfWhich statement is true with regards to acetylation of histones  Dea.pdf
Which statement is true with regards to acetylation of histones Dea.pdf
 
Which of the following is not a measure of variabilitya) Variance.pdf
Which of the following is not a measure of variabilitya) Variance.pdfWhich of the following is not a measure of variabilitya) Variance.pdf
Which of the following is not a measure of variabilitya) Variance.pdf
 
What is the maximum probability of committing a Type I error called.pdf
What is the maximum probability of committing a Type I error called.pdfWhat is the maximum probability of committing a Type I error called.pdf
What is the maximum probability of committing a Type I error called.pdf
 

Recently uploaded

Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
AnaAcapella
 
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
heathfieldcps1
 
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
QucHHunhnh
 

Recently uploaded (20)

Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
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
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Asian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptxAsian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptx
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
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
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
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
 
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
 

C++ ProgramN-number queue rotations.[16] Write methods void Que.pdf

  • 1. C++ Program: N-number queue rotations. [16] Write methods void Queue::lRotate(int n) and void Queue::rRotate(int n) which rotate the queue by n-number elements. Solution void rRotate(int& root){ item* tmpRoot = itemArray[root]; int ogLeft = tmpRoot->left; tmpRoot->left = itemArray[ogLeft]->right; itemArray[ogLeft]->right = root; root = ogLeft; //to be made the (sub)root outside the method } void lRotate(int& root){ item* tmpRoot = itemArray[root]; int ogRight = tmpRoot->right; tmpRoot->right = itemArray[ogRight]->left; itemArray[ogRight]->left = root; root = ogRight; //to be made the (sub)root outside the method }