Programming Data Structures and Algorithms questions

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…

0/90 correct0 marks

Related topics in GATE DA