Recent questions and answers in Algorithms

10 10 votes
4 4 answers
1.7k
1.7k views
Let $G(V, E)$ be a simple, undirected, edge-weighted graph with unique edge weights.Which of the following statements about the minimum spanning trees (MST) of $G$ is/are...
13 13 votes
6 answers 6 answers
1.4k
1.4k views
Consider a standard Dijkstra algorithm that works as follows: The queue is initialized with the usual initial values.While Queue is not empty Step 1: Extract the minimum ...
91 91 votes
10 10 answers
70.6k
70.6k views
There are $n$ unsorted arrays: $A_1, A_2, \dots, A_n$. Assume that $n$ is odd.Each of $A_1, A_2, \dots, A_n$ contains $n$ distinct elements. There are no common elements ...
53 53 votes
8 answers 8 answers
22.2k
22.2k views
What does the following algorithm approximate? (Assume $m 1, \epsilon >0$).x = m; y = 1; While (x-y ϵ) { x = (x+y)/2; y = m/x; } print(x);$\log \, m$$m^2$$m^{\frac{1}{2...
61 61 votes
5 answers 5 answers
25.4k
25.4k views
Consider a double hashing scheme in which the primary hash function is $h_1(k)= k \text{ mod } 23$, and the secondary hash function is $h_2(k)=1+(k \text{ mod } 19)$. Ass...
45 45 votes
6 6 answers
3.0k
3.0k views
The following diagram shows the set of edges (in thick black lines) selected at some intermediate step of an MST algorithm. Lighter edges are not yet in MST. Assume that ...
48 48 votes
3 3 answers
2.0k
2.0k views
Given an undirected, weighted graph $\mathrm{G}$ with positive, integer edge weights, we want to find a path shortest path from $u$ to $v$ with the below condition.The co...
63 63 votes
9 answers 9 answers
25.8k
25.8k views
Consider the following recurrence relation:$T(n)=\left\{\begin{array}{c}\sqrt{n} T(\sqrt{n})+n \text { for } n \geq 1, \\ 1 \quad \text { for } n=1\end{array}\right.$Whic...
138 138 votes
19 answers 19 answers
81.6k
81.6k views
The minimum number of comparisons required to find the minimum and the maximum of $100$ numbers is ________
137 137 votes
19 answers 19 answers
46.4k
46.4k views
A list of $n$ strings, each of length $n$, is sorted into lexicographic order using the merge-sort algorithm. The worst case running time of this computation is$O (n \log...
30 30 votes
6 answers 6 answers
2.8k
2.8k views
Let $T(n)$ be$$T(n)= \begin{cases}2 T(n / 2)+8 T(n / 4)+n^{2} & \text { if } n \geq 4 \\1 & \text { if } n \leq 3\end{cases}$$What will be asymptotic bound on $T(n)?$ $\T...
33 33 votes
4 4 answers
19.6k
19.6k views
​​​​​An array $[82,101,90,11,111,75,33,131,44,93]$ is heapified. Which one of the following options represents the first three elements in the heapified array?$82,90,101$...
119 119 votes
22 answers 22 answers
57.1k
57.1k views
Let $G$ be a complete undirected graph on $4$ vertices, having $6$ edges with weights being $1, 2, 3, 4, 5,$ and $6$. The maximum possible weight that a minimum weight s...
109 109 votes
13 answers 13 answers
39.4k
39.4k views
Consider the following functions$f(n) = 3n^{\sqrt{n}}$$g(n) = 2^{\sqrt{n}{\log_{2}n}}$$h(n) = n!$Which of the following is true?$h(n)$ is $O(f(n))$$h(n)$ is $O(g(n))$$g(n...
103 103 votes
7 answers 7 answers
31.6k
31.6k views
Let $G$ be a graph with $100!$ vertices, with each vertex labelled by a distinct permutation of the numbers $1, 2,\ldots, 100.$ There is an edge between vertices $u$ and ...
127 127 votes
11 answers 11 answers
33.4k
33.4k views
In an adjacency list representation of an undirected simple graph $G=(V, E)$, each edge $(u, v)$ has two adjacency list entries: $[v]$ in the adjacency list of $u$, and $...
0 0 votes
0 0 answers
74
74 views
Q.${Solve}$ ${Recurrence}$.$T(n) = T\left(\frac{n}{15}\right) + T\left(\frac{n}{10}\right) + 2T\left(\frac{n}{6}\right) + \sqrt{n}$ 
2 2 votes
2 2 answers
184
184 views
Which of the following statements is/are FALSE?If all edge weights of $\mathrm{G}=(\mathrm{V}, \mathrm{E})$ are distinct, the MST of a graph G is unique. Removing the max...
24 24 votes
5 5 answers
2.4k
2.4k views
Consider a source which outputs independent random letters from the alphabet $A=$ $\{a, b, c, d, e\}$ with probabilities $p_{a}=1 / 4, p_{b}=1 / 4, p_{c}=1 / 6, p_{d}=1 /...
9 9 votes
4 4 answers
1.9k
1.9k views
Find total number of scalar multiplications of a matrix-chain product of $6$ matrices whose sequence of dimensions is $5, 10, 3, 12, 5, 50$ and $6.$ That is $5\times 10$ ...
60 60 votes
6 answers 6 answers
22.5k
22.5k views
Kruskal’s algorithm for finding a minimum spanning tree of a weighted graph $G$ with $n$ vertices and $m$ edges has the time complexity of:$O(n^{2})$$O(mn)$$O(m+n)$$O(m \...
1 1 vote
1 1 answer
213
213 views
You have given an array A[] = {12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1}. An inversion in an array A is a pair of array indices (i, j) such that i < j and A[i] A[j]. Assume...
32 32 votes
7 7 answers
2.4k
2.4k views
Select the correct asymptotic complexity of an algorithm with runtime $T(n, n)$ where$T(x, c)=\Theta(x) \quad$ for $c \leq 2$,$T(c, y)=\Theta(y) \quad$ for $c \leq 2$, an...
36 36 votes
4 4 answers
2.4k
2.4k views
Consider mutually recursive definitions of $T(a, b)$ and $S(c, d)$ :$$\begin{array}{rlr}T(x, c) & =\Theta(x) & \text { for } c \leq 2 \\T(x, y) & =\Theta(x)+S(x, y / 2), ...
11 11 votes
4 4 answers
1.5k
1.5k views
Let $X=x_{1} x_{2} \cdots x_{m}$ and $Y=y_{1} y_{2} \cdots y_{n}$ be two strings over the alphabet $\displaystyle{}\Sigma= \{\mathrm{A}, \mathrm{C}, \mathrm{G}, \mathrm{T...
23 23 votes
3 3 answers
1.6k
1.6k views
You are working on a dynamic programming problem defined by the recurrence:\[ A(i, j) = F\!\big( A(\lfloor i/2 \rfloor,\, j),\; A(i,\, \lfloor j/2 \rfloor) \big), \]where...
37 37 votes
4 4 answers
14.9k
14.9k views
​​​​Which of the following statements regarding Breadth First Search (BFS) and Depth First Search (DFS) on an undirected simple graph $G$ is/are TRUE?A DFS tree of $G$ is...
3 3 votes
1 1 answer
333
333 views
Let $G$ be a directed graph with nonnegative edge weights, and let $s$ and $t$ be vertices of $G$.Consider the statement:Any shortest path from $s$ to $t$ in $G$ is also ...
3 3 votes
1 1 answer
242
242 views
During sorting, one complete processing of all elements whose final positions have not yet been determined is called a pass.Which of the following sequences cannot be the...
3 3 votes
1 1 answer
171
171 views
An initially empty hash table $\text{HT}$ has length $11$.The hash function is:$H(key)=key \bmod 7$Collisions are resolved using linear probing.The following keys are ins...
3 3 votes
1 1 answer
219
219 views
The algorithm $\text{ALGSORT}$ sorts an array of distinct integers using comparisons.The function $\text{MININDEX(V,i,j)}$ returns the position of the smallest element in...
1 1 vote
1 1 answer
176
176 views
Consider the following statement:For every connected weighted graph $G$, there exists some vertex $v$ such that a shortest path tree rooted at $v$ is identical to a minim...
2 2 votes
1 1 answer
170
170 views
Consider a simple version of Bellman-Ford algorithm where we initialize $\text{distTo}[s]$ to $0$ and the rest of $\text{distTo}[v]$ to $+\infty$. Then fix an order on al...
1 1 vote
1 1 answer
164
164 views
Consider Dijkstra's algorithm on a graph having $V$ vertices and $E$ edges.Suppose an indexed priority queue is not used.Instead, the tentative distances are stored only ...
1 1 vote
1 1 answer
117
117 views
Consider a directed edge $e = v \to w$ with weight $7$. Suppose that during a shortest path algorithm:$\operatorname{distTo}[v] = 16$ and $\operatorname{distTo}[w] = 25$...
1 1 vote
1 1 answer
154
154 views
Suppose Huffman coding is implemented as follows.Initially, the $n$ symbols are stored in a min priority queue according to their frequencies.The algorithm repeatedly per...
1 1 vote
1 1 answer
162
162 views
Let, $G=(V,E)$ be a connected undirected graph. Edge weights may be negative.We want to choose, $E'\subseteq E$ such that $G'=(V,E')$ is connected and: $\sum_{e\in E'}w(e...
0 0 votes
1 1 answer
161
161 views
Let $G=(V,E)$ be a directed graph with positive edge weights.Given vertices $s,w,t$ we want the length of the shortest path from $s$ to $t$ that must pass through $w$.Con...
2 2 votes
1 1 answer
130
130 views
What is the primary reason to use Floyd's algorithm for the all-pairs shortest-path problem instead of Dijkstra's algorithm?Faster for dense graphs. Faster for sparse gra...
1 1 vote
1 1 answer
207
207 views
Which of the following cannot be a sequence of keys compared during a binary search for some target key?$500,200,450,180$ $500,450,200,180$ $180,500,200,450$ $180,200,500...
To see more, click for all the questions in this category.