SlideShare a Scribd company logo
1 of 1
Download to read offline
The Queue is a special memory structure with accesses limited to PUSH and POP operations
which result in a firstinfirstout (FIFO) access. The Stack is a related memory structure which
also has two operations PUSH and POP, but unlike the Queue, the POP operation results in the
data value entered using the most recent PUSH operation.
This results in a lastinfirstout (LIFO) access. Implementing a queue treats the memory as a
circle. How would you modify this design to implement a Stack? How are the Stack Empty and
Stack conditions checked?
Solution
we can Implement stack with using 2 Queues.
In this the first method we ensure that the new entry of element is always at top of queue1 , so
that the pop operation just dequeue from queue 1. We here are using the other queue "queue2"
to make sure that the new element is always at the top of queue1.
Below is the operation of the implemented stack:
PUSH :
step 1 : Enqueue element to Queue2.
step 2 : Now gradually dequeueing each element from Queue1 and enqueue to Queue2.
step 3 : Interchanging the name of the Queues with each other. So that we can dont allow one
more movement of all elements from Queue2 Queue1.
POP :
step 1 : Dequeue a element from Queue1 and return it.
STACK_EMPTY :
step 1 : we can check that by cheking the state of Queue1 , if it is empty than the stack is
empty.

More Related Content

Similar to The Queue is a special memory structure with accesses limited to PUS.pdf

Similar to The Queue is a special memory structure with accesses limited to PUS.pdf (20)

Stacks
StacksStacks
Stacks
 
Stack - Operations and Applications
Stack - Operations and ApplicationsStack - Operations and Applications
Stack - Operations and Applications
 
Stack and Queue.pptx
Stack and Queue.pptxStack and Queue.pptx
Stack and Queue.pptx
 
queue.pptx
queue.pptxqueue.pptx
queue.pptx
 
Queue AS an ADT (Abstract Data Type)
Queue AS an ADT (Abstract Data Type)Queue AS an ADT (Abstract Data Type)
Queue AS an ADT (Abstract Data Type)
 
unit 5 stack & queue.ppt
unit 5 stack & queue.pptunit 5 stack & queue.ppt
unit 5 stack & queue.ppt
 
Stack
StackStack
Stack
 
Stack and its operations
Stack and its operationsStack and its operations
Stack and its operations
 
Study & Analysis of Complexities of Stack & Queue Operations in Data Structure
Study & Analysis of Complexities of Stack & Queue Operations in Data StructureStudy & Analysis of Complexities of Stack & Queue Operations in Data Structure
Study & Analysis of Complexities of Stack & Queue Operations in Data Structure
 
Queue - Operations and Implementations
Queue - Operations and ImplementationsQueue - Operations and Implementations
Queue - Operations and Implementations
 
Stack and its operations, Queue and its operations
Stack and its operations, Queue and its operationsStack and its operations, Queue and its operations
Stack and its operations, Queue and its operations
 
Queue Data Structure
Queue Data StructureQueue Data Structure
Queue Data Structure
 
Data Structure Lecture 4
Data Structure Lecture 4Data Structure Lecture 4
Data Structure Lecture 4
 
Stacks
StacksStacks
Stacks
 
Stacks in Data Structure
Stacks in Data StructureStacks in Data Structure
Stacks in Data Structure
 
stack_presentaton_HUSNAIN[2].pojklklklptx
stack_presentaton_HUSNAIN[2].pojklklklptxstack_presentaton_HUSNAIN[2].pojklklklptx
stack_presentaton_HUSNAIN[2].pojklklklptx
 
What is Stack? Application of Stack
What is Stack? Application of StackWhat is Stack? Application of Stack
What is Stack? Application of Stack
 
Queue
QueueQueue
Queue
 
Stacks and Queue,Concept of Stack,LIFO,Fifo,
Stacks and Queue,Concept of Stack,LIFO,Fifo,Stacks and Queue,Concept of Stack,LIFO,Fifo,
Stacks and Queue,Concept of Stack,LIFO,Fifo,
 
Stacks IN DATA STRUCTURES
Stacks IN DATA STRUCTURESStacks IN DATA STRUCTURES
Stacks IN DATA STRUCTURES
 

More from eyewaregallery

in C++ , Design a linked list class named IntegerList to hold a seri.pdf
in C++ , Design a linked list class named IntegerList to hold a seri.pdfin C++ , Design a linked list class named IntegerList to hold a seri.pdf
in C++ , Design a linked list class named IntegerList to hold a seri.pdfeyewaregallery
 
In addition to the fossil record, what other kinds of evidence reinfo.pdf
In addition to the fossil record, what other kinds of evidence reinfo.pdfIn addition to the fossil record, what other kinds of evidence reinfo.pdf
In addition to the fossil record, what other kinds of evidence reinfo.pdfeyewaregallery
 
How much 0.521 M NaOH will be needed to raise the pH of 0.161 L of 4.pdf
How much 0.521 M NaOH will be needed to raise the pH of 0.161 L of 4.pdfHow much 0.521 M NaOH will be needed to raise the pH of 0.161 L of 4.pdf
How much 0.521 M NaOH will be needed to raise the pH of 0.161 L of 4.pdfeyewaregallery
 
I am writing a program that places bolcks on a grid the the sape of .pdf
I am writing a program that places bolcks on a grid the the sape of .pdfI am writing a program that places bolcks on a grid the the sape of .pdf
I am writing a program that places bolcks on a grid the the sape of .pdfeyewaregallery
 
How do teams bring value to an organizationHow are high performin.pdf
How do teams bring value to an organizationHow are high performin.pdfHow do teams bring value to an organizationHow are high performin.pdf
How do teams bring value to an organizationHow are high performin.pdfeyewaregallery
 
how can we use empricism to figure out if a fact is trueSolutio.pdf
how can we use empricism to figure out if a fact is trueSolutio.pdfhow can we use empricism to figure out if a fact is trueSolutio.pdf
how can we use empricism to figure out if a fact is trueSolutio.pdfeyewaregallery
 
Gene RegulationFunction of transcription factor domains, i.e. DNA.pdf
Gene RegulationFunction of transcription factor domains, i.e. DNA.pdfGene RegulationFunction of transcription factor domains, i.e. DNA.pdf
Gene RegulationFunction of transcription factor domains, i.e. DNA.pdfeyewaregallery
 
For each step of DNA replication, predict the outcome ifconcentra.pdf
For each step of DNA replication, predict the outcome ifconcentra.pdfFor each step of DNA replication, predict the outcome ifconcentra.pdf
For each step of DNA replication, predict the outcome ifconcentra.pdfeyewaregallery
 
Explain THREE unique characteristics of fungi.SolutionThree un.pdf
Explain THREE unique characteristics of fungi.SolutionThree un.pdfExplain THREE unique characteristics of fungi.SolutionThree un.pdf
Explain THREE unique characteristics of fungi.SolutionThree un.pdfeyewaregallery
 
Explain the basic relationship between humans and microorganisms.pdf
Explain the basic relationship between humans and microorganisms.pdfExplain the basic relationship between humans and microorganisms.pdf
Explain the basic relationship between humans and microorganisms.pdfeyewaregallery
 
discuss the rationale for the global harmonization of financial repo.pdf
discuss the rationale for the global harmonization of financial repo.pdfdiscuss the rationale for the global harmonization of financial repo.pdf
discuss the rationale for the global harmonization of financial repo.pdfeyewaregallery
 
Describe the need to multitask in BBC (behavior-based control) syste.pdf
Describe the need to multitask in BBC (behavior-based control) syste.pdfDescribe the need to multitask in BBC (behavior-based control) syste.pdf
Describe the need to multitask in BBC (behavior-based control) syste.pdfeyewaregallery
 
A spinner with 7 equally sized slices is shown below. The dial is spu.pdf
A spinner with 7 equally sized slices is shown below. The dial is spu.pdfA spinner with 7 equally sized slices is shown below. The dial is spu.pdf
A spinner with 7 equally sized slices is shown below. The dial is spu.pdfeyewaregallery
 
ble below to calculate the Gross Domestic Product uning the ral Gro.pdf
ble below to calculate the Gross Domestic Product uning the ral Gro.pdfble below to calculate the Gross Domestic Product uning the ral Gro.pdf
ble below to calculate the Gross Domestic Product uning the ral Gro.pdfeyewaregallery
 
1.The limbic systemA. matures before the prefrontal cortexB. is.pdf
1.The limbic systemA. matures before the prefrontal cortexB. is.pdf1.The limbic systemA. matures before the prefrontal cortexB. is.pdf
1.The limbic systemA. matures before the prefrontal cortexB. is.pdfeyewaregallery
 
Why is leadership a critical factor in implementing change and qua.pdf
Why is leadership a critical factor in implementing change and qua.pdfWhy is leadership a critical factor in implementing change and qua.pdf
Why is leadership a critical factor in implementing change and qua.pdfeyewaregallery
 
Why are there bubbles in beer and champagneSolution Bubbles of .pdf
Why are there bubbles in beer and champagneSolution  Bubbles of .pdfWhy are there bubbles in beer and champagneSolution  Bubbles of .pdf
Why are there bubbles in beer and champagneSolution Bubbles of .pdfeyewaregallery
 
Which of the following is true of a traditional master budget a. It.pdf
Which of the following is true of a traditional master budget a. It.pdfWhich of the following is true of a traditional master budget a. It.pdf
Which of the following is true of a traditional master budget a. It.pdfeyewaregallery
 
Which ethnic groups were a part of the former YugoslaviaCroats, S.pdf
Which ethnic groups were a part of the former YugoslaviaCroats, S.pdfWhich ethnic groups were a part of the former YugoslaviaCroats, S.pdf
Which ethnic groups were a part of the former YugoslaviaCroats, S.pdfeyewaregallery
 
What would the components of the development be in an early learning.pdf
What would the components of the development be in an early learning.pdfWhat would the components of the development be in an early learning.pdf
What would the components of the development be in an early learning.pdfeyewaregallery
 

More from eyewaregallery (20)

in C++ , Design a linked list class named IntegerList to hold a seri.pdf
in C++ , Design a linked list class named IntegerList to hold a seri.pdfin C++ , Design a linked list class named IntegerList to hold a seri.pdf
in C++ , Design a linked list class named IntegerList to hold a seri.pdf
 
In addition to the fossil record, what other kinds of evidence reinfo.pdf
In addition to the fossil record, what other kinds of evidence reinfo.pdfIn addition to the fossil record, what other kinds of evidence reinfo.pdf
In addition to the fossil record, what other kinds of evidence reinfo.pdf
 
How much 0.521 M NaOH will be needed to raise the pH of 0.161 L of 4.pdf
How much 0.521 M NaOH will be needed to raise the pH of 0.161 L of 4.pdfHow much 0.521 M NaOH will be needed to raise the pH of 0.161 L of 4.pdf
How much 0.521 M NaOH will be needed to raise the pH of 0.161 L of 4.pdf
 
I am writing a program that places bolcks on a grid the the sape of .pdf
I am writing a program that places bolcks on a grid the the sape of .pdfI am writing a program that places bolcks on a grid the the sape of .pdf
I am writing a program that places bolcks on a grid the the sape of .pdf
 
How do teams bring value to an organizationHow are high performin.pdf
How do teams bring value to an organizationHow are high performin.pdfHow do teams bring value to an organizationHow are high performin.pdf
How do teams bring value to an organizationHow are high performin.pdf
 
how can we use empricism to figure out if a fact is trueSolutio.pdf
how can we use empricism to figure out if a fact is trueSolutio.pdfhow can we use empricism to figure out if a fact is trueSolutio.pdf
how can we use empricism to figure out if a fact is trueSolutio.pdf
 
Gene RegulationFunction of transcription factor domains, i.e. DNA.pdf
Gene RegulationFunction of transcription factor domains, i.e. DNA.pdfGene RegulationFunction of transcription factor domains, i.e. DNA.pdf
Gene RegulationFunction of transcription factor domains, i.e. DNA.pdf
 
For each step of DNA replication, predict the outcome ifconcentra.pdf
For each step of DNA replication, predict the outcome ifconcentra.pdfFor each step of DNA replication, predict the outcome ifconcentra.pdf
For each step of DNA replication, predict the outcome ifconcentra.pdf
 
Explain THREE unique characteristics of fungi.SolutionThree un.pdf
Explain THREE unique characteristics of fungi.SolutionThree un.pdfExplain THREE unique characteristics of fungi.SolutionThree un.pdf
Explain THREE unique characteristics of fungi.SolutionThree un.pdf
 
Explain the basic relationship between humans and microorganisms.pdf
Explain the basic relationship between humans and microorganisms.pdfExplain the basic relationship between humans and microorganisms.pdf
Explain the basic relationship between humans and microorganisms.pdf
 
discuss the rationale for the global harmonization of financial repo.pdf
discuss the rationale for the global harmonization of financial repo.pdfdiscuss the rationale for the global harmonization of financial repo.pdf
discuss the rationale for the global harmonization of financial repo.pdf
 
Describe the need to multitask in BBC (behavior-based control) syste.pdf
Describe the need to multitask in BBC (behavior-based control) syste.pdfDescribe the need to multitask in BBC (behavior-based control) syste.pdf
Describe the need to multitask in BBC (behavior-based control) syste.pdf
 
A spinner with 7 equally sized slices is shown below. The dial is spu.pdf
A spinner with 7 equally sized slices is shown below. The dial is spu.pdfA spinner with 7 equally sized slices is shown below. The dial is spu.pdf
A spinner with 7 equally sized slices is shown below. The dial is spu.pdf
 
ble below to calculate the Gross Domestic Product uning the ral Gro.pdf
ble below to calculate the Gross Domestic Product uning the ral Gro.pdfble below to calculate the Gross Domestic Product uning the ral Gro.pdf
ble below to calculate the Gross Domestic Product uning the ral Gro.pdf
 
1.The limbic systemA. matures before the prefrontal cortexB. is.pdf
1.The limbic systemA. matures before the prefrontal cortexB. is.pdf1.The limbic systemA. matures before the prefrontal cortexB. is.pdf
1.The limbic systemA. matures before the prefrontal cortexB. is.pdf
 
Why is leadership a critical factor in implementing change and qua.pdf
Why is leadership a critical factor in implementing change and qua.pdfWhy is leadership a critical factor in implementing change and qua.pdf
Why is leadership a critical factor in implementing change and qua.pdf
 
Why are there bubbles in beer and champagneSolution Bubbles of .pdf
Why are there bubbles in beer and champagneSolution  Bubbles of .pdfWhy are there bubbles in beer and champagneSolution  Bubbles of .pdf
Why are there bubbles in beer and champagneSolution Bubbles of .pdf
 
Which of the following is true of a traditional master budget a. It.pdf
Which of the following is true of a traditional master budget a. It.pdfWhich of the following is true of a traditional master budget a. It.pdf
Which of the following is true of a traditional master budget a. It.pdf
 
Which ethnic groups were a part of the former YugoslaviaCroats, S.pdf
Which ethnic groups were a part of the former YugoslaviaCroats, S.pdfWhich ethnic groups were a part of the former YugoslaviaCroats, S.pdf
Which ethnic groups were a part of the former YugoslaviaCroats, S.pdf
 
What would the components of the development be in an early learning.pdf
What would the components of the development be in an early learning.pdfWhat would the components of the development be in an early learning.pdf
What would the components of the development be in an early learning.pdf
 

Recently uploaded

會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文中 央社
 
When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...Gary Wood
 
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading RoomSternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading RoomSean M. Fox
 
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjjStl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjjMohammed Sikander
 
Major project report on Tata Motors and its marketing strategies
Major project report on Tata Motors and its marketing strategiesMajor project report on Tata Motors and its marketing strategies
Major project report on Tata Motors and its marketing strategiesAmanpreetKaur157993
 
SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code ExamplesPeter Brusilovsky
 
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...EADTU
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...Nguyen Thanh Tu Collection
 
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...Nguyen Thanh Tu Collection
 
Đề tieng anh thpt 2024 danh cho cac ban hoc sinh
Đề tieng anh thpt 2024 danh cho cac ban hoc sinhĐề tieng anh thpt 2024 danh cho cac ban hoc sinh
Đề tieng anh thpt 2024 danh cho cac ban hoc sinhleson0603
 
How to Send Pro Forma Invoice to Your Customers in Odoo 17
How to Send Pro Forma Invoice to Your Customers in Odoo 17How to Send Pro Forma Invoice to Your Customers in Odoo 17
How to Send Pro Forma Invoice to Your Customers in Odoo 17Celine George
 
diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....Ritu480198
 
SURVEY I created for uni project research
SURVEY I created for uni project researchSURVEY I created for uni project research
SURVEY I created for uni project researchCaitlinCummins3
 
Trauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical PrinciplesTrauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical PrinciplesPooky Knightsmith
 
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUMDEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUMELOISARIVERA8
 
MOOD STABLIZERS DRUGS.pptx
MOOD     STABLIZERS           DRUGS.pptxMOOD     STABLIZERS           DRUGS.pptx
MOOD STABLIZERS DRUGS.pptxPoojaSen20
 
How to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptxHow to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptxCeline George
 
AIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptAIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptNishitharanjan Rout
 
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfFICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfPondicherry University
 

Recently uploaded (20)

會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
 
When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...
 
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading RoomSternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
 
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjjStl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
 
Major project report on Tata Motors and its marketing strategies
Major project report on Tata Motors and its marketing strategiesMajor project report on Tata Motors and its marketing strategies
Major project report on Tata Motors and its marketing strategies
 
SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code Examples
 
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
 
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
 
Đề tieng anh thpt 2024 danh cho cac ban hoc sinh
Đề tieng anh thpt 2024 danh cho cac ban hoc sinhĐề tieng anh thpt 2024 danh cho cac ban hoc sinh
Đề tieng anh thpt 2024 danh cho cac ban hoc sinh
 
How to Send Pro Forma Invoice to Your Customers in Odoo 17
How to Send Pro Forma Invoice to Your Customers in Odoo 17How to Send Pro Forma Invoice to Your Customers in Odoo 17
How to Send Pro Forma Invoice to Your Customers in Odoo 17
 
diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....
 
SURVEY I created for uni project research
SURVEY I created for uni project researchSURVEY I created for uni project research
SURVEY I created for uni project research
 
Trauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical PrinciplesTrauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical Principles
 
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUMDEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
 
MOOD STABLIZERS DRUGS.pptx
MOOD     STABLIZERS           DRUGS.pptxMOOD     STABLIZERS           DRUGS.pptx
MOOD STABLIZERS DRUGS.pptx
 
How to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptxHow to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptx
 
Mattingly "AI & Prompt Design: Named Entity Recognition"
Mattingly "AI & Prompt Design: Named Entity Recognition"Mattingly "AI & Prompt Design: Named Entity Recognition"
Mattingly "AI & Prompt Design: Named Entity Recognition"
 
AIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptAIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.ppt
 
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfFICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
 

The Queue is a special memory structure with accesses limited to PUS.pdf

  • 1. The Queue is a special memory structure with accesses limited to PUSH and POP operations which result in a firstinfirstout (FIFO) access. The Stack is a related memory structure which also has two operations PUSH and POP, but unlike the Queue, the POP operation results in the data value entered using the most recent PUSH operation. This results in a lastinfirstout (LIFO) access. Implementing a queue treats the memory as a circle. How would you modify this design to implement a Stack? How are the Stack Empty and Stack conditions checked? Solution we can Implement stack with using 2 Queues. In this the first method we ensure that the new entry of element is always at top of queue1 , so that the pop operation just dequeue from queue 1. We here are using the other queue "queue2" to make sure that the new element is always at the top of queue1. Below is the operation of the implemented stack: PUSH : step 1 : Enqueue element to Queue2. step 2 : Now gradually dequeueing each element from Queue1 and enqueue to Queue2. step 3 : Interchanging the name of the Queues with each other. So that we can dont allow one more movement of all elements from Queue2 Queue1. POP : step 1 : Dequeue a element from Queue1 and return it. STACK_EMPTY : step 1 : we can check that by cheking the state of Queue1 , if it is empty than the stack is empty.