Question 50

CS2MSQ2 marksNeeds review
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

is emptied by popping all elements. Then queue

is emptied by dequeuing 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 are possible valid assignment(s) of the elements?
Note: In the options, the notation

denotes that element

was assigned to

and

denotes that element

was assigned to

.
Your answerSelect all correct options. You can choose more than one.

Log in to check the answer

You can attempt this question now. Sign in to view the answer key, explanations and discussion.Log in to check answer

EXPLORE & PRACTISE

Paper and topic context

See where this question comes from and choose what to practise next.

2026CS2

GATE CSE 2026 · Paper 2

Computer Science and Information Technology · Original paper archive

Section
Section CS2
Question type
Multiple select (MSQ)
Marks
2 marks

Practise related topics

Explore more previous year questions using this question’s imported topic tags.

computer science

GATE CSE previous year questions

information technology

GATE CSE previous year questions

computing

GATE CSE previous year questions

programming data structures

GATE CSE previous year questions

Programming and Data Structures

GATE CSE previous year questions

Comments

Ask a question, share your approach, or help someone understand.

Log in to view the discussion

You’re not logged in. Log in or create an account to see discussions and add comments.