When you add Questions to a Stack, you add it to a Queue. All of your questions are in a single, unified list that works just like a queue in the real ticketing world. Provided with four types of question from easiest to hardest, these challenging Question and Answer will help you master the Concepts. This set of Problems of Queue using Stacks from various competitive examinations will help you prepare for any exam including BCA, MCA, GATE, GRE, IES, PSC, UGC NET, DOEACC Exams at all levels – you just have to practice regularly. With the stacking strategy you will solve most of these questions in a very short time.

## Queue using Stacks MCQs and Answers

**1. A Double-ended queue supports operations such as adding and removing items from both the sides of the queue. They support four operations like addFront (adding item to top of the queue), addRear (adding item to the bottom of the queue), removeFront (removing item from the top of the queue) and removeRear (removing item from the bottom of the queue). You are given only stacks to implement this data structure. You can implement only push and pop operations. What are the total number of stacks required for this operation?**

a) 1

b) 2

c) 3

d) 4

**Answer: **2

**2. You are asked to perform a queue operation using a stack. Assume the size of the stack is some value ‘n’ and there are ‘m’ number of variables in this stack. The time complexity of performing deQueue operation is (Using only stack operations like push and pop)(Tightly bound).**

a) O(m)

b) O(n)

c) O(m*n)

d) Data is insufficient

**Answer: **O(m)

**3. Consider you have an array of some random size. You need to perform dequeue operation. You can perform it using stack operation (push and pop) or using queue operations itself (enQueue and Dequeue). The output is guaranteed to be same. Find some differences?**

a) They will have different time complexities

b) The memory used will not be different

c) There are chances that output might be different

d) No differences

**Answer: **They will have different time complexities

**4. Consider you have a stack whose elements in it are as follows.**

5 4 3 2 << top

Where the top element is 2.

You need to get the following stack

6 5 4 3 2 << top

The operations that needed to be performed are (You can perform only push and pop):

a) Push(pop()), push(6), push(pop())

b) Push(pop()), push(6)

c) Push(pop()), push(pop()), push(6)

d) Push(6)

**Answer: **Push(pop()), push(6), push(pop())

**5. A double-ended queue supports operations like adding and removing items from both the sides of the queue. They support four operations like addFront (adding item to top of the queue), addRear (adding item to the bottom of the queue), removeFront (removing item from the top of the queue) and removeRear (removing item from the bottom of the queue). You are given only stacks to implement this data structure. You can implement only push and pop operations. What’s the time complexity of performing addFront and addRear? (Assume ‘m’ to be the size of the stack and ‘n’ to be the number of elements)**

a) O(m) and O(n)

b) O(1) and O(n)

c) O(n) and O(1)

d) O(n) and O(m)

**Answer: **O(1) and O(n)

**6. Why is implementation of stack operations on queues not feasible for a large dataset (Asssume the number of elements in the stack to be n)?**

a) Because of its time complexity O(n)

b) Because of its time complexity O(log(n))

c) Extra memory is not required

d) There are no problems

**Answer: **Because of its time complexity O(n)

**7. Consider yourself to be in a planet where the computational power of chips to be slow. You have an array of size 10. You want to perform enqueue some element into this array. But you can perform only push and pop operations. Push and pop operation both take 1 sec respectively. The total time required to perform enQueue operation is?**

a) 20

b) 40

c) 42

d) 43

**Answer: **43

**8. You have two jars, one jar which has 10 rings and the other has none. They are placed one above the other. You want to remove the last ring in the jar. And the second jar is weak and cannot be used to store rings for a long time.**

a) Empty the first jar by removing it one by one from the first jar and placing it into the second jar

b) Empty the first jar by removing it one by one from the first jar and placing it into the second jar and empty the second jar by placing all the rings into the first jar one by one

c) There exists no possible way to do this

d) Break the jar and remove the last one

**Answer: **Empty the first jar by removing it one by one from the first jar and placing it into the second jar and empty the second jar by placing all the rings into the first jar one by one

**9. Given only a single array of size 10 and no other memory is available. Which of the following operation is not feasible to implement (Given only push and pop operation)?**

a) Push

b) Pop

c) Enqueue

d) Returntop

**Answer: **Enqueue

**10. Given an array of size n, let’s assume an element is ‘touched’ if and only if some operation is performed on it (for example, for performing a pop operation the top element is ‘touched’). Now you need to perform Dequeue operation. Each element in the array is touched atleast?**

a) Once

b) Twice

c) Thrice

d) Four times

**Answer:** Four times