SlideShare a Scribd company logo
Write an algorithm in pseudocode called copy Stack that copies the contents of one stack into
another. The algorithm passes two stacks, the source stack and the destination stack. The order of
the stacks must be identical. Write an algorithm in pseudocode that reverses the contents of a
queue.
Solution
1)Stack S = source, Stack d=destination, int size = no of element;
while(size >0 ) {
pop size-1 elements from S and ,
push them in D
pop the last element and maintain copy of last element ; push last element to S;
pop and push (size-1 elements ) into D back to the S.
push copy of the last element in D
size--;
}
2) int a[100];
struct stack p;
for(int i=0;i

More Related Content

More from badshetoms

9. How much would it cost to construct a building today that cost $12.pdf
9. How much would it cost to construct a building today that cost $12.pdf9. How much would it cost to construct a building today that cost $12.pdf
9. How much would it cost to construct a building today that cost $12.pdf
badshetoms
 
True or false 20. A manufacturer has a duty to warn about risks that.pdf
True or false 20. A manufacturer has a duty to warn about risks that.pdfTrue or false 20. A manufacturer has a duty to warn about risks that.pdf
True or false 20. A manufacturer has a duty to warn about risks that.pdf
badshetoms
 
to a 1911 in an effort to reduce violence against Suffragettes of NAW.pdf
to a 1911 in an effort to reduce violence against Suffragettes of NAW.pdfto a 1911 in an effort to reduce violence against Suffragettes of NAW.pdf
to a 1911 in an effort to reduce violence against Suffragettes of NAW.pdf
badshetoms
 
There are many cases of human disease where an enzyme activity is lac.pdf
There are many cases of human disease where an enzyme activity is lac.pdfThere are many cases of human disease where an enzyme activity is lac.pdf
There are many cases of human disease where an enzyme activity is lac.pdf
badshetoms
 
The United states has utilize multiple forms of liberalism through o.pdf
The United states has utilize multiple forms of liberalism through o.pdfThe United states has utilize multiple forms of liberalism through o.pdf
The United states has utilize multiple forms of liberalism through o.pdf
badshetoms
 
Calculator 26 ng Learning pose that the Fed engages in expansionary.pdf
Calculator 26 ng Learning pose that the Fed engages in expansionary.pdfCalculator 26 ng Learning pose that the Fed engages in expansionary.pdf
Calculator 26 ng Learning pose that the Fed engages in expansionary.pdf
badshetoms
 
Silver chromate is sparingly soluble in aqueous solutions. The Ksp o.pdf
Silver chromate is sparingly soluble in aqueous solutions. The Ksp o.pdfSilver chromate is sparingly soluble in aqueous solutions. The Ksp o.pdf
Silver chromate is sparingly soluble in aqueous solutions. The Ksp o.pdf
badshetoms
 
Problem 21.12 Histone genes are unusual among eukaryotic genes becaus.pdf
Problem 21.12 Histone genes are unusual among eukaryotic genes becaus.pdfProblem 21.12 Histone genes are unusual among eukaryotic genes becaus.pdf
Problem 21.12 Histone genes are unusual among eukaryotic genes becaus.pdf
badshetoms
 
Privacy and Security What types of health care data are protected u.pdf
Privacy and Security What types of health care data are protected u.pdfPrivacy and Security What types of health care data are protected u.pdf
Privacy and Security What types of health care data are protected u.pdf
badshetoms
 
1. Project risk is normally highest during the project Executing Pro.pdf
1. Project risk is normally highest during the project Executing Pro.pdf1. Project risk is normally highest during the project Executing Pro.pdf
1. Project risk is normally highest during the project Executing Pro.pdf
badshetoms
 
PLEASE HELP ME !!IT IS Due Tonight ;(!How can I make the add but.pdf
PLEASE HELP ME !!IT IS Due Tonight ;(!How can I make the add but.pdfPLEASE HELP ME !!IT IS Due Tonight ;(!How can I make the add but.pdf
PLEASE HELP ME !!IT IS Due Tonight ;(!How can I make the add but.pdf
badshetoms
 
Part AAxonemal dyneins areAxonemal dyneins areassociated with ci.pdf
Part AAxonemal dyneins areAxonemal dyneins areassociated with ci.pdfPart AAxonemal dyneins areAxonemal dyneins areassociated with ci.pdf
Part AAxonemal dyneins areAxonemal dyneins areassociated with ci.pdf
badshetoms
 
Manufacturing company that is considering Linux as a solution for so.pdf
Manufacturing company that is considering Linux as a solution for so.pdfManufacturing company that is considering Linux as a solution for so.pdf
Manufacturing company that is considering Linux as a solution for so.pdf
badshetoms
 
C programming.   For this code I only need to add a function so th.pdf
C programming.   For this code I only need to add a function so th.pdfC programming.   For this code I only need to add a function so th.pdf
C programming.   For this code I only need to add a function so th.pdf
badshetoms
 
Modern Algebra With respect to addition show that the set of Even .pdf
Modern Algebra With respect to addition show that the set of Even .pdfModern Algebra With respect to addition show that the set of Even .pdf
Modern Algebra With respect to addition show that the set of Even .pdf
badshetoms
 
Looks like the questions has been ask before but isnt answered cor.pdf
Looks like the questions has been ask before but isnt answered cor.pdfLooks like the questions has been ask before but isnt answered cor.pdf
Looks like the questions has been ask before but isnt answered cor.pdf
badshetoms
 
List and briefly describe Diversity & InclusionSolutionDiversi.pdf
List and briefly describe Diversity & InclusionSolutionDiversi.pdfList and briefly describe Diversity & InclusionSolutionDiversi.pdf
List and briefly describe Diversity & InclusionSolutionDiversi.pdf
badshetoms
 
Java Language.....pdf
Java Language.....pdfJava Language.....pdf
Java Language.....pdf
badshetoms
 
compare and contrast the matrix and the allegorySolutionThe ma.pdf
compare and contrast the matrix and the allegorySolutionThe ma.pdfcompare and contrast the matrix and the allegorySolutionThe ma.pdf
compare and contrast the matrix and the allegorySolutionThe ma.pdf
badshetoms
 
Imagine that you want to keep track of your pet fish. Each fish is a.pdf
Imagine that you want to keep track of your pet fish. Each fish is a.pdfImagine that you want to keep track of your pet fish. Each fish is a.pdf
Imagine that you want to keep track of your pet fish. Each fish is a.pdf
badshetoms
 

More from badshetoms (20)

9. How much would it cost to construct a building today that cost $12.pdf
9. How much would it cost to construct a building today that cost $12.pdf9. How much would it cost to construct a building today that cost $12.pdf
9. How much would it cost to construct a building today that cost $12.pdf
 
True or false 20. A manufacturer has a duty to warn about risks that.pdf
True or false 20. A manufacturer has a duty to warn about risks that.pdfTrue or false 20. A manufacturer has a duty to warn about risks that.pdf
True or false 20. A manufacturer has a duty to warn about risks that.pdf
 
to a 1911 in an effort to reduce violence against Suffragettes of NAW.pdf
to a 1911 in an effort to reduce violence against Suffragettes of NAW.pdfto a 1911 in an effort to reduce violence against Suffragettes of NAW.pdf
to a 1911 in an effort to reduce violence against Suffragettes of NAW.pdf
 
There are many cases of human disease where an enzyme activity is lac.pdf
There are many cases of human disease where an enzyme activity is lac.pdfThere are many cases of human disease where an enzyme activity is lac.pdf
There are many cases of human disease where an enzyme activity is lac.pdf
 
The United states has utilize multiple forms of liberalism through o.pdf
The United states has utilize multiple forms of liberalism through o.pdfThe United states has utilize multiple forms of liberalism through o.pdf
The United states has utilize multiple forms of liberalism through o.pdf
 
Calculator 26 ng Learning pose that the Fed engages in expansionary.pdf
Calculator 26 ng Learning pose that the Fed engages in expansionary.pdfCalculator 26 ng Learning pose that the Fed engages in expansionary.pdf
Calculator 26 ng Learning pose that the Fed engages in expansionary.pdf
 
Silver chromate is sparingly soluble in aqueous solutions. The Ksp o.pdf
Silver chromate is sparingly soluble in aqueous solutions. The Ksp o.pdfSilver chromate is sparingly soluble in aqueous solutions. The Ksp o.pdf
Silver chromate is sparingly soluble in aqueous solutions. The Ksp o.pdf
 
Problem 21.12 Histone genes are unusual among eukaryotic genes becaus.pdf
Problem 21.12 Histone genes are unusual among eukaryotic genes becaus.pdfProblem 21.12 Histone genes are unusual among eukaryotic genes becaus.pdf
Problem 21.12 Histone genes are unusual among eukaryotic genes becaus.pdf
 
Privacy and Security What types of health care data are protected u.pdf
Privacy and Security What types of health care data are protected u.pdfPrivacy and Security What types of health care data are protected u.pdf
Privacy and Security What types of health care data are protected u.pdf
 
1. Project risk is normally highest during the project Executing Pro.pdf
1. Project risk is normally highest during the project Executing Pro.pdf1. Project risk is normally highest during the project Executing Pro.pdf
1. Project risk is normally highest during the project Executing Pro.pdf
 
PLEASE HELP ME !!IT IS Due Tonight ;(!How can I make the add but.pdf
PLEASE HELP ME !!IT IS Due Tonight ;(!How can I make the add but.pdfPLEASE HELP ME !!IT IS Due Tonight ;(!How can I make the add but.pdf
PLEASE HELP ME !!IT IS Due Tonight ;(!How can I make the add but.pdf
 
Part AAxonemal dyneins areAxonemal dyneins areassociated with ci.pdf
Part AAxonemal dyneins areAxonemal dyneins areassociated with ci.pdfPart AAxonemal dyneins areAxonemal dyneins areassociated with ci.pdf
Part AAxonemal dyneins areAxonemal dyneins areassociated with ci.pdf
 
Manufacturing company that is considering Linux as a solution for so.pdf
Manufacturing company that is considering Linux as a solution for so.pdfManufacturing company that is considering Linux as a solution for so.pdf
Manufacturing company that is considering Linux as a solution for so.pdf
 
C programming.   For this code I only need to add a function so th.pdf
C programming.   For this code I only need to add a function so th.pdfC programming.   For this code I only need to add a function so th.pdf
C programming.   For this code I only need to add a function so th.pdf
 
Modern Algebra With respect to addition show that the set of Even .pdf
Modern Algebra With respect to addition show that the set of Even .pdfModern Algebra With respect to addition show that the set of Even .pdf
Modern Algebra With respect to addition show that the set of Even .pdf
 
Looks like the questions has been ask before but isnt answered cor.pdf
Looks like the questions has been ask before but isnt answered cor.pdfLooks like the questions has been ask before but isnt answered cor.pdf
Looks like the questions has been ask before but isnt answered cor.pdf
 
List and briefly describe Diversity & InclusionSolutionDiversi.pdf
List and briefly describe Diversity & InclusionSolutionDiversi.pdfList and briefly describe Diversity & InclusionSolutionDiversi.pdf
List and briefly describe Diversity & InclusionSolutionDiversi.pdf
 
Java Language.....pdf
Java Language.....pdfJava Language.....pdf
Java Language.....pdf
 
compare and contrast the matrix and the allegorySolutionThe ma.pdf
compare and contrast the matrix and the allegorySolutionThe ma.pdfcompare and contrast the matrix and the allegorySolutionThe ma.pdf
compare and contrast the matrix and the allegorySolutionThe ma.pdf
 
Imagine that you want to keep track of your pet fish. Each fish is a.pdf
Imagine that you want to keep track of your pet fish. Each fish is a.pdfImagine that you want to keep track of your pet fish. Each fish is a.pdf
Imagine that you want to keep track of your pet fish. Each fish is a.pdf
 

Recently uploaded

Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
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
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Thiyagu K
 
Chapter -12, Antibiotics (One Page Notes).pdf
Chapter -12, Antibiotics (One Page Notes).pdfChapter -12, Antibiotics (One Page Notes).pdf
Chapter -12, Antibiotics (One Page Notes).pdf
Kartik Tiwari
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
Multithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race conditionMultithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race condition
Mohammed Sikander
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
Peter Windle
 
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
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
SACHIN R KONDAGURI
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
Vikramjit Singh
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
vaibhavrinwa19
 
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
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
Group Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana BuscigliopptxGroup Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana Buscigliopptx
ArianaBusciglio
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 
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
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
Jisc
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
thanhdowork
 

Recently uploaded (20)

Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
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
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 
Chapter -12, Antibiotics (One Page Notes).pdf
Chapter -12, Antibiotics (One Page Notes).pdfChapter -12, Antibiotics (One Page Notes).pdf
Chapter -12, Antibiotics (One Page Notes).pdf
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
Multithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race conditionMultithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race condition
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
 
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 ...
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
 
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
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
Group Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana BuscigliopptxGroup Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana Buscigliopptx
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 
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.
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
 

Write an algorithm in pseudocode called copy Stack that copies the co.pdf

  • 1. Write an algorithm in pseudocode called copy Stack that copies the contents of one stack into another. The algorithm passes two stacks, the source stack and the destination stack. The order of the stacks must be identical. Write an algorithm in pseudocode that reverses the contents of a queue. Solution 1)Stack S = source, Stack d=destination, int size = no of element; while(size >0 ) { pop size-1 elements from S and , push them in D pop the last element and maintain copy of last element ; push last element to S; pop and push (size-1 elements ) into D back to the S. push copy of the last element in D size--; } 2) int a[100]; struct stack p; for(int i=0;i