Data Science and Artificial Intelligence
GATE DA Programming, Data Structures and Algorithms PYQs
Build your understanding with focused practice from past exam papers.
Questions 21–30 of 31. Imported answers require independent review unless marked reviewed.
Question 21
Open questionDAMCQ1 markNeeds review
Consider performing uniform hashing on an open address hash table with load factor
, where
elements are stored in the table with
slots. The expected number of probes in unsuccessful search is at most
. Inserting an element in this hash table requires at most _____ probes, on average.Your answerChoose one option.
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 answerQuestion 28
Open questionDAMSQ1 markNeeds review
Consider the following tree traversals on a full binary tree:
(i) Preorder
(ii) Inorder
(iii) Postorder
Which of the following traversal options is/are sufficient to uniquely reconstruct the full binary tree?
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 answerQuestion 30
Open questionDANAT1 markNeeds review
Consider sorting the following array of integers in ascending order using an in-place Quicksort algorithm that uses the last element as the pivot.
60 70 80 90 100
The minimum number of swaps performed during this Quicksort is ______.
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 answerQuestion 32
Open questionDANAT1 markNeeds review
The fundamental operations in a double-ended queue D are:
insertFirst(e) – Insert a new element e at the beginning of D.
insertLast(e) – Insert a new element e 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 ← removeFirst()
insertLast(28)
insertLast(17)
a ← removeFirst()
a ← removeLast()
The value of a is _____.
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 answerQuestion 38
Open questionDAMCQ2 marksNeeds review
Consider the following Python code:
def count(child_dict, i):
if i not in child_dict.keys():
return 1
ans = 1
for j in child_dict[i]:
ans += count(child_dict, j)
return ans
child_dict = dict()
child_dict[0] = [1,2]
child_dict[1] = [3,4,5]
child_dict[2] = [6,7,8]
print(count(child_dict,0))
Which ONE of the following is the output of this code?
Your answerChoose one option.
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 answerQuestion 39
Open questionDAMCQ2 marksNeeds review
Consider the function
whose pseudocode is given below:computes(X)
S[1] ← 1
for i ← 2 to length(X)
S[i] ← 1
if X[i − 1] ≤ X[i]
S[i] ← S[i] + S[i − 1]
end if
end for
return S
Which ONE of the following values is returned by the function
for
?Your answerChoose one option.
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 answerQuestion 40
Open questionDAMCQ2 marksNeeds review
Let
denote the maximum number of comparisons made while searching for an entry in a sorted array of size
using binary search.Which ONE of the following options is TRUE?
Your answerChoose one option.
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 answerQuestion 41
Open questionDAMCQ2 marksNeeds review
Consider the following Python function:
def fun(D, s1, s2):
if s1 < s2:
D[s1], D[s2] = D[s2], D[s1]
fun(D, s1+1, s2-1)
What does this Python function
do? Select the ONE appropriate option below.Your answerChoose one option.
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 answerQuestion 45
Open questionDAMCQ2 marksNeeds review
Consider the following sorting algorithms:
(i) Bubble sort
(ii) Insertion sort
(iii) Selection sort
Which ONE among the following choices of sorting algorithms sorts the numbers in the array [4,3,2,1,5] in increasing order after exactly two passes over the array?
Your answerChoose one option.
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 answerQuestion 51
Open questionDAMSQ2 marksNeeds review
Consider the directed acyclic graph (DAG) below:

Which of the following are valid vertex orderings that can be obtained from a topological sort of the DAG?
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