# 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?

+1 vote
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 a Dequeue operation. Each element in the array is touched at least?

(a) Once

(b) Twice

(c) Thrice

(d) Four times

+1 vote
by (506k points)
selected by

Correct option is (d) Four times

To explain: First each element from the first stack is popped, then pushed into the second stack, dequeue operation is done on the top of the stack and later the each element of second stack is popped then pushed into the first stack. Therfore each element is touched four times.

+1 vote
+1 vote
+1 vote
+1 vote
+1 vote
+1 vote
+1 vote
+1 vote
+1 vote
+1 vote
+1 vote