Use app×
QUIZARD
QUIZARD
JEE MAIN 2026 Crash Course
NEET 2026 Crash Course
CLASS 12 FOUNDATION COURSE
CLASS 10 FOUNDATION COURSE
CLASS 9 FOUNDATION COURSE
CLASS 8 FOUNDATION COURSE
0 votes
758 views
in Information Technology by (72.8k points)
closed by
A stack can be implemented using queue, but then we need to use atleast:
1. 3 queues
2. 2 queues
3. only one queue is sufficient
4. none of the options

1 Answer

0 votes
by (121k points)
selected by
 
Best answer
Correct Answer - Option 2 : 2 queues

A stack can be implemented using two queues. Let stack to be implemented be ‘x’ and queues used to implement be ‘a’ and ‘b’.

Method 1 (By push operation)
This method makes sure that the newly entered element is always at the front of ‘a’, so that pop operation just dequeues from ‘a’. ‘b’ is used to put every new element at front of ‘b’.

Method 2 (By making pop operation costly)
In a push operation, the new element is always enqueued to a. In pop() operation, if b is empty then all the elements except the last, are moved to b. Finally, the last element is dequeued from a and returned.

Therefore Option 2 is correct

Welcome to Sarthaks eConnect: A unique platform where students can interact with teachers/experts/students to get solutions to their queries. Students (upto class 10+2) preparing for All Government Exams, CBSE Board Exam, ICSE Board Exam, State Board Exam, JEE (Mains+Advance) and NEET can ask questions from any subject and get quick answers by subject teachers/ experts/mentors/students.

Categories

...