Stacks, Queues and Linked Lists: GATE DA Previous Year Questions

Stacks, Queues and Linked Lists · Programming, Data Structures and Algorithms

3 questions · asked in 2 of 3 years (2024–2026)

MCQ 1 · NAT 21-mark 2 · 2-mark 1

2024Questions per year2026

Questions 1–3 of 3

Q1GATE 20252 marksNAT
Consider the following pseudocode.  

    Create empty stack S
    Set x=0, flag=0, sum=0
    Push x onto S
    while (S is not empty){
        if (flag equals 0){
            Set x = x+1
            Push x onto S}
        if (x equals 8):
            Set flag=1
        if (flag equals 1){
            x = Pop(S)
            if (x is odd):
                Pop(S)
            Set sum = sum + x}
    }
    Output sum
  The value of sum output by a program executing the above pseudocode is ___________ (Answer in integer)

Q2GATE 20241 markMCQ−0.33 if wrong
Match the items in Column 1 with the items in Column 2 in the following table:

Column 1Column 2(p) First In First Out(i) Stacks (q) Lookup Operation(ii) Queues(r) Last In First Out(iii) Hash Tables\begin{array}{|l|l|} \hline \text{Column 1} & \text{Column 2} \\ \hline (p) \text{ First In First Out} & \text{(i) Stacks }\\ \hline (q) \text{ Lookup Operation} & \text{(ii) Queues}\\ \hline (r) \text{ Last In First Out} & \text{(iii) Hash Tables}\\ \hline \end{array}

Q3GATE 20241 markNAT
The fundamental operations in a double-ended queue D are:

insertFirst(e) - Insert a new element ee at the beginning of DD.
insertLast(e) - Insert a new element ee at the end of D .
removeFirst()-Remove and return the first element of D.
removeLast () - Remove and return the last element of D.

In an empty double-ended queue, the following operations are performed:

insertFirst (10)
insertLast (32)
a←a \leftarrow removeFirst ()
insertLast (28)
insertLast(17)
a←a \leftarrow removeFirst ()
a←{a} \leftarrow removeLast ()

The value of a{a} is _________ .

Keep practising

Topics in Programming, Data Structures and Algorithms

All DA topics ›