Home / CSE MCQs / Data Structure MCQs :: Discussion

Discussion :: Data Structure MCQs

  1. Making the pop operation costly, select the code snippet which implements the same.
  2. A.

    public int pop()


    {


    B.

    public int pop()


    {


    C.

    public int pop()


    {


    D.
    None of the mentioned

    View Answer

    Workspace

    Answer : Option C

    Explanation :

    Here the pop operation is costly, hence we need two queues, other than the first element, all the the elements from one queue are dequeued and enqueued to the second queue, hence only one element remains in the first queue which is the item we want, so dequeue it and return the result.


Be The First To Comment