Programming Data Structures and Algorithms questions — page 1 of 2

Q15

GATE DA 2026 DADivide and ConquerMCQ1 mark−1/3 if wrong

Report a problem with Q15

What is wrong?
Consider that the quick sort algorithm is used to sort an array of nn distinct randomly ordered elements. In every call, the pivot is chosen as the first element of the current subarray.
Let T(n)T(n) denote the expected time to sort the array. Assume that the time to partition is linear in the size of the current subarray.
Which of the following recurrence relations correctly represents T(n)T(n) in this scenario?
Show answer without attempting

Loading the answer…

Q16

GATE DA 2026 DAProgramming in PythonMCQ1 mark−1/3 if wrong

Report a problem with Q16

What is wrong?
Consider the given Python program.
def append_to_lst(val, lst=[]):
    lst.append(val)
    return lst
print(append_to_lst(1))
print(append_to_lst(2))
print(append_to_lst(3, []))
Which of the following is the correct output of this program?
Show answer without attempting

Loading the answer…

Q25

GATE DA 2026 DAData StructuresMSQ1 mark

Report a problem with Q25

What is wrong?
You are given the following Pre-order and In-order traversals of a Binary Tree T with nodes E, F, G, P, Q, R, S.
Pre-order: P Q S E R F G
In-order: S Q E P F R G
Which of the following statements is/are true about the Binary Tree T?
More than one option can be correct.
Show answer without attempting

Loading the answer…

Q31

GATE DA 2026 DASearching and SortingNAT1 mark

Report a problem with Q31

What is wrong?
Let A be a sorted array containing 1000 distinct integers. You perform a recursive binary search on A to find an element y. Suppose each comparison checks whether the middle element computed during the current recursive step is equal to, less than, or greater than y.
The maximum number of comparisons that may have to be performed if y is not an element of A is _______ . (Answer in integer)
Show answer without attempting

Loading the answer…

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…

Q40

GATE DA 2026 DAGraph Theory and Graph AlgorithmsMCQ2 marks−2/3 if wrong

Report a problem with Q40

What is wrong?
Consider a directed graph G=(V,E)G = (V, E), where VV is the finite set of vertices and EE is the set of directed edges between the vertices. GG may contain cycles but there is no self-loop. Further, GG may not be strongly connected.
Let GRG^R be the graph obtained by reversing the directions of all the edges in GG without changing the set of vertices.
Assume that Breadth First Search (BFS) or Depth First Search (DFS) from any given vertex vv of a graph visits only the reachable vertices from vv in that graph.
Which of the following statements must always be true, regardless of the structure of GG?
Show answer without attempting

Loading the answer…

Q49

GATE DA 2026 DASearching and SortingMSQ2 marks

Report a problem with Q49

What is wrong?
Consider the problem of sorting the given array in ascending order:
P = [1, 2, 3, 5, 4]
Consider two sorting algorithms Bubble Sort (BS) and Insertion Sort (IS).
Let N1 be the total number of comparisons done by BS on the elements of P and N2 be the total number of comparisons done by IS on the elements of P.
Which of the following options is/are correct?
More than one option can be correct.
Show answer without attempting

Loading the answer…

Q50

GATE DA 2026 DAProgramming in PythonMSQ2 marks

Report a problem with Q50

What is wrong?
Consider the given Python program.
def outer():
    x = []
    def inner(val):
        x.append(val)
        return x
    return inner
f1 = outer()
f2 = outer()
print(f1(10)) # Line P
print(f1(20)) # Line Q
print(f2(30)) # Line R
print(f1(40)) # Line S
Which of the following options is/are correct?
More than one option can be correct.
Show answer without attempting

Loading the answer…

Q58

GATE DA 2026 DAProgramming in PythonNAT2 marks

Report a problem with Q58

What is wrong?
Consider the given Python program.
def fun(L, i=0):
    if i >= len(L)-1:
        return 0
    if L[i] > L[i+1]:
        L[i+1], L[i] = L[i], L[i+1]
        return 1+fun(L, i+1)
    else:
        return fun(L, i+1)

data = [5, 3, 4, 1, 2]
count = 0
for _ in range(len(data)):
    count += fun(data)
print(count)
The output of the program is __________ . (Answer in integer)
Show answer without attempting

Loading the answer…

Q18

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

Report a problem with Q18

What is wrong?
Consider a hash table of size 10 with indices {0,1,…,9}\{0, 1, \ldots, 9\}, with the hash function
h(x)=3x(mod10),h(x) = 3x \pmod{10},
where linear probing is used to handle collisions. The hash table is initially empty and then the following sequence of keys is inserted into the hash table: 1, 4, 5, 6, 14, 15. The indices where the keys 14 and 15 are stored are, respectively
Show answer without attempting

Loading the answer…

Q23

GATE DA 2025 DAProgramming in PythonMCQ1 mark−1/3 if wrong

Report a problem with Q23

What is wrong?
Consider the following Python declarations of two lists.
A=[1,2,3]
B=[4,5,6]
Which one of the following statements results in A= [1, 2, 3, 4, 5, 6]?
Show answer without attempting

Loading the answer…

Q27

GATE DA 2025 DASearching and SortingMSQ1 mark

Report a problem with Q27

What is wrong?
For which of the following inputs does binary search take time O(log⁡n)O(\log n) in the worst case?
More than one option can be correct.
Show answer without attempting

Loading the answer…

Q29

GATE DA 2025 DASearching and SortingMSQ1 mark

Report a problem with Q29

What is wrong?
Suppose that insertion sort is applied to the array [1,3,5,7,9,11,x,15,13][1, 3, 5, 7, 9, 11, x, 15, 13] and it takes exactly two swaps to sort the array. Select all possible values of xx.
More than one option can be correct.
Show answer without attempting

Loading the answer…

Q47

GATE DA 2025 DAProgramming in PythonMCQ2 marks−2/3 if wrong

Report a problem with Q47

What is wrong?
Consider the following Python code snippet.
A={"this","that"}
B={"that","other"}
C={"other","this"}
while "other" in C:
    if "this" in A:
        A,B,C=A-B,B-C,C-A
    if "that" in B:
        A,B,C=C|A,A|B,B|C
When the above program is executed, at the end, which of the following sets contains "this"?
Show answer without attempting

Loading the answer…

Q58

GATE DA 2025 DAGraph Theory and Graph AlgorithmsMSQ2 marks

Report a problem with Q58

What is wrong?
Let GG be a simple, unweighted, and undirected graph. A subset of the vertices and edges of GG are shown below.

It is given that a−b−c−da - b - c - d is a shortest path between aa and dd; e−f−g−he - f - g - h is a shortest path between ee and hh; a−f−c−ha - f - c - h is a shortest path between aa and hh. Which of the following is/are NOT the edges of GG?
Question figure
More than one option can be correct.
Show answer without attempting

Loading the answer…

Q63

GATE DA 2025 DAProgramming in PythonNAT2 marks

Report a problem with Q63

What is wrong?
Consider the following Python code snippet.
def f(a,b):
    if (a==0):
        return b
    if (a%2==1):
        return 2*f((a-1)/2,b)
    return b+f(a-1,b)

print(f(15,10))
The value printed by the code snippet is __________ (Answer in integer)
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…

Q65

GATE DA 2025 DAGraph Theory and Graph AlgorithmsNAT2 marks

Report a problem with Q65

What is wrong?
Consider a directed graph G=(V,E)G = (V, E), where V={0,1,2,…,100}V = \{0, 1, 2, \ldots, 100\} and E={(i,j):0<j−i≤2,for all i,j∈V}E = \{(i, j) : 0 < j - i \le 2, \text{for all } i, j \in V\}. Suppose the adjacency list of each vertex is in decreasing order of vertex number, and depth-first search (DFS) is performed at vertex 0. The number of vertices that will be discovered after vertex 50 is __________ (Answer in integer)
Show answer without attempting

Loading the answer…

Q14

GATE DA 2024 DAGraph Theory and Graph AlgorithmsMCQ1 mark−1/3 if wrong

Report a problem with Q14

What is wrong?
Consider performing depth-first search (DFS) on an undirected and unweighted graph GG starting at vertex ss. For any vertex uu in GG, d[u]d[u] is the length of the shortest path from ss to uu. Let (u,v)(u, v) be an edge in GG such that d[u]<d[v]d[u] < d[v]. If the edge (u,v)(u, v) is explored first in the direction from uu to vv during the above DFS, then (u,v)(u, v) becomes a ______ edge.
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/200 correct0 marks

Related topics in GATE DA