PYQBOOK
Filter Questions
Found 585 question(s)
Q1
MCQ
GATE
CS
Medium
1 Mark
2026 Shift-1
ALGORITHM → RECURRENCE RELATIONS
Consider the following recurrence relations:
For all $n>1$
$T_{1}(n)=4T_{1}(\frac{n}{2})+T_{2}(n)$
$T_{2}(n)=5T_{2}(\frac{n}{4})+\Theta(log_{2}n)$
Assume that for all $n\le1$, $T_{1}(n)=1$ and $T_{2}(n)=1$.
Which one of the following options is correct?
Q2
MSQ
GATE
CS
Easy
2 Marks
2026 Shift-1
ALGORITHM → GRAPH TRAVERSAL
An undirected, unweighted, simple graph $G(V,E)$ is said to be 2-colorable if there exists a function $c:V\rightarrow\{0,1\}$ such that for every $(u,v)\in E$, $c(u)\ne c(v)$. Which of the following statements about 2-colorable graphs is/are true?
Q3
MSQ
GATE
CS
Medium
2 Marks
2026 Shift-1
ALGORITHM → GRAPH TRAVERSAL
Consider the following pseudocode for depth-first search (DFS) algorithm which takes a directed graph $G(V,E)$ as input, where $d[v]$ and $f[v]$ are the discovery time and finishing time, respectively, of the vertex $v\in V$.
Explore(G,v,t)
mark v
t = t + 1
d[v] = t
for each (v,w) in E
if w is unmarked
t = Explore(G,w,t)
end if
end for
t = t + 1
f[v] = t
return t
DFS(G):
unmark all v in V
t = 0
for each v in V
if v is unmarked
t = Explore(G,v,t)
end if
end for
Suppose that the input directed graph $G(V,E)$ is a directed acyclic graph (DAG). For an edge $(u,v)\in E$, which of the following options will NEVER be correct?
Explore(G,v,t)
mark v
t = t + 1
d[v] = t
for each (v,w) in E
if w is unmarked
t = Explore(G,w,t)
end if
end for
t = t + 1
f[v] = t
return t
DFS(G):
unmark all v in V
t = 0
for each v in V
if v is unmarked
t = Explore(G,v,t)
end if
end for
Q4
MCQ
GATE
CS
Medium
2 Marks
2026 Shift-1
ALGORITHM → SHORTEST PATH
Let $G(V,E)$ be an undirected, edge-weighted graph with integer weights. The weight of a path is the sum of the weights of the edges in that path. The length of a path is the number of edges in that path.
Let $s\in V$ be a vertex in G. For every $u\in V$ and for every $k\ge0$ let $d_{k}(u)$ denote the weight of a shortest path (in terms of weight) from s to u of length at most k. If there is no path from s to u of length at most k, then $d_{k}(u)=\infty.$
Consider the statements:
S1: For every $k\ge0$ and $u\in V$, $d_{k+1}(u)\le d_{k}(u)$.
S2: For every $(u,v)\in E$, if $(u,v)$ is part of a shortest path (in terms of weight) from s to v, then for every $k\ge0$, $d_{k}(u)\le d_{k}(v)$.
Which one of the following options is correct?
Q5
MSQ
GATE
CS
Medium
2 Marks
2026 Shift-1
ALGORITHM → MINIMUM SPANNING TREE