Computer Sciences > GATE 2026 SET-2 > Data Structures
Consider a stack π and a queue π. Both of them are initially empty and have the
capacity to store ten elements each. The elements 1,2,3,4, and 5 arrive one by one,
in that order. When an element arrives, it is assigned either to π (pushed on π ) or
to π (enqueued to π). Once all the five elements are stored, the output is generated
in two steps. First, stack S is emptied by popping all elements.
Then queue π is emptied by dequeueing all elements. The output obtained by following this process is 4 3 1 2 5 . Given the output, the objective is to predict whether an element was assigned to π or π.
Which of the following options is/are possible valid assignment(s) of the elements?
Note: In the options, the notation π₯π denotes that element π₯ was assigned to π and yπ denotes that element π¦ was assigned to π.
Then queue π is emptied by dequeueing all elements. The output obtained by following this process is 4 3 1 2 5 . Given the output, the objective is to predict whether an element was assigned to π or π.
Which of the following options is/are possible valid assignment(s) of the elements?
Note: In the options, the notation π₯π denotes that element π₯ was assigned to π and yπ denotes that element π¦ was assigned to π.
Correct : a,b
Similar Questions
Which one of the following sequences when stored in an array at locations
A[1],...,A[10] forms a max-heap?
Let SLLdel be a function that deletes a node in a singly-linked list given a pointer to the node and a pointer to the head of the list. Similarly, let DLLdel be...
An algorithm has to store several keys generated by an adversary in a hash table. The adversary is malicious who tries to maximize the number of collisions. Let...
Total Unique Visitors
Loading......