Filter by year

Stacks questions

Q39

GATE DA 2026 DAData StructuresMCQ2 marks−2/3 if wrong

Report a problem with Q39

What is wrong?
A recursive function in Python is given.
def mystery(n):
    if n <= 0:
        return 1
    else:
        return mystery(n-1) + mystery(n-2)
Now, consider the following function call:
mystery(4)
Assume that a typical runtime stack is used to manage function calls. Each function call is pushed onto the stack and removed only after it finishes execution.
Which of the following options denotes the total number of function calls (i.e., the total number of stack activations), including the initial call, to compute mystery(4)?
Show answer without attempting

Loading the answer…

Q64

GATE DA 2025 DAData StructuresNAT2 marks

Report a problem with Q64

What is wrong?
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)
Show answer without attempting

Loading the answer…

Q16

GATE DA 2024 DAData StructuresMCQ1 mark−1/3 if wrong

Report a problem with Q16

What is 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
Show answer without attempting

Loading the answer…

0/30 correct0 marks

Related topics in Data Structures