1. Home
  2. Programming and Data Stru...

Filters

Found 1 Question

Set Default
Exams
Subjects
Topics

List of top Programming and Data Structures Questions on Stacks and Queues

Consider a stack \(S\) and a queue \(Q\). 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 \(S\) (pushed on \(S\)) or to \(Q\) (enqueued to \(Q\)). 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 \(Q\) 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 \(S\) or \(Q\).

Which of the following options is/are possible valid assignment(s) of the elements?

Note: In the options, the notation \(xS\) denotes that element \(x\) was assigned to \(S\) and \(yQ\) denotes that element \(y\) was assigned to \(Q\).
  • GATE CS - 2026
  • GATE CS
  • Programming and Data Structures
  • Stacks and Queues
contact us
terms & conditions
Privacy & Policy
© 2026 Patronum Web Private Limited