A stack is implemented using queue(s); q1 is the queue that stores the stack's…
A stack is implemented using queue(s); q1 is the queue that stores the stack's elements. The Java method below is one of the operations of that stack.
public void fun(int x) {
q1.offer(x);
}
Which stack operation does this method perform, and in this implementation which operation - push() or pop() - is the costlier one?
- A.
Perform push() with push as the costlier operation
- B.
Perform push() with pop as the costlier operation
- C.
Perform pop() with push as the costlier operation
- D.
More than one of the above
- E.
None of the above
Attempted by 17 students.
Sign up free to check your answer
Sign up freeLoading lesson…