GATEverse
← GATE CSE 2026 Set 2

Q40

MSQ2 marks

Consider a stack SS and a queue QQ. Both of them are initially empty and have the capacity to store ten elements each. The elements 1,2,3,41,2,3,4, and 55 arrive one by one, in that order. When an element arrives, it is assigned either to SS (pushed on SS ) or to QQ (enqueued to QQ ). 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 QQ is emptied by dequeueing all elements. The output obtained by following this process is 4312543125. Given the output, the objective is to predict whether an element was assigned to SS or QQ. Which of the following options is/are possible valid assignment(s) of the elements? Note: In the options, the notation xSx S denotes that element xx was assigned to SS and yQy Q denotes that element yy was assigned to QQ.

Sign in to save attempts.

Loading…