Recent questions tagged goclasses-algorithms-practice-questions

5 5 votes
2 2 answers
577
577 views
Which of the following statements is/are correct?A.Merge sort always has more number of swaps that comparisonsNumber of comparisons in partition algorithm are same for be...
5 5 votes
2 2 answers
1.2k
1.2k views
Suppose four characters A, B, C, D have the frequencies $15, 8, 6,$ and $5$, respectively. After constructing the optimal Huffman code for this alphabet, what is the tota...
5 5 votes
3 3 answers
1.2k
1.2k views
A project manager has broken down a project into $8$ tasks: $A, B, C, D, E, F, G,$ and $H$. The dependencies between the tasks are shown in the directed graph below. A va...
5 5 votes
2 2 answers
796
796 views
An algorithm performs a linear search for an element $k$ in an integer array of size $N$. The algorithm iterates through the array sequentially, starting from the first e...
9 9 votes
2 2 answers
826
826 views
Let $S$ be a sorted array of $n$ distinct positive integers. Let $T(n)$ denote the time complexity of the most efficient algorithm to determine if there exist three indic...
6 6 votes
2 2 answers
647
647 views
If one uses the binary exponentiation (exponentiation by squaring) method to compute $a^{55}$, which of the following intermediate powers of $a$ is calculated but NOT use...
8 8 votes
3 3 answers
819
819 views
Let G be a connected, undirected graph of $50$ vertices and $200$ edges. The weight of a minimum spanning tree of G is $800$ . When the weight of each edge of G is decrea...
6 6 votes
4 4 answers
993
993 views
The number of distinct minimum spanning trees for the weighted graph below is____________ 
5 5 votes
3 3 answers
584
584 views
Consider a graph with the following weighted edges: Which one of the following sequences cannot be the order of edges added to a Minimum Spanning Tree (MST) using Kruskal...
5 5 votes
2 2 answers
549
549 views
Arrange the following functions by their asymptotic growth rate in increasing order.$f_1(n)=(\log n)^{\log n}$ $f_2(n)=2^{\sqrt{\log _2 n}}$ $f_3(n)=n^{1 / 3}(\log n)^3$ ...
6 6 votes
2 2 answers
601
601 views
Consider the following three statements regarding asymptotic notation:I. $\log \left(n^c\right)=\Theta(\log n)$ where $c>0$ is a constantII. $3^{n+5}=\Theta\left(3^n\righ...
4 4 votes
2 2 answers
519
519 views
Consider the following weighted, undirected graph:What is the total weight of the Minimum Spanning Tree (MST) for this graph?
3 3 votes
3 3 answers
503
503 views
Among the following sequences:I. $GDFHACBE$II. $GHFACDBE$III. $GHDACFBE$IV. $GFDHCABE$Which of the following are possible breadth-first traversals of the graph, starting ...
3 3 votes
1 1 answer
497
497 views
Among the following sequences:I. $A B E C F G D H$II. $A D G F C H B E$III. $ACFGBDEH$IV. $ADHFGCBE$Which of the following are possible depth-first traversals (DFS) of th...
2 2 votes
2 2 answers
480
480 views
Among the following sequences:I. abefghII. afehbgIII. abghefIV. aebfhgWhich are the possible depth-first traversals of the modified graph, starting from node 'a'?I and II...
4 4 votes
2 2 answers
452
452 views
Suppose we run Dijkstra's single-source shortest path algorithm on the following edge-weighted directed graph with vertex $\mathbf{S}$ as the source. (Assume alphabetical...
2 2 votes
3 3 answers
745
745 views
3 3 votes
3 3 answers
545
545 views
Assume that a Bubble Sort algorithm in the worst case takes $\mathbf{2 5}$ seconds for an input of size $\mathbf{5 0}$. Which of the following most closely approximates t...
4 4 votes
4 4 answers
546
546 views
If one uses a straight two-way merge sort algorithm to sort the following elements in ascending order:$$50,10,35,80,22,5,70,45,18,60,25,90$$then the order of these elemen...
2 2 votes
3 3 answers
461
461 views
Let $C_1, C_2, C_3$, and $C_4$ be four matrices of dimensions $40 \times 20,20 \times 30,30 \times 10$, and $10 \times$ 30 , respectively. The minimum number of scalar mu...
0 0 votes
2 2 answers
408
408 views
Let $B_1, B_2, B_3, B_4$, and $B_5$ be five matrices of dimensions $20 \times 10,10 \times 30,30 \times 5,5 \times 40$, and $40 \times 15$, respectively. The minimum numb...
3 3 votes
2 2 answers
473
473 views
Let $f(n)=2^{2^n}$ and $g(n)=n$ ! be two positive functions of $n$.Which of the following statements correctly describes the asymptotic relationship between them?(Note: $...
1 1 vote
1 1 answer
339
339 views
Define $C_n$ to be the minimum cost to acquire a total rod length of exactly $n$ meters. You can purchase rods of standard integer lengths, and for $i>0$, let $\operatorn...
1 1 vote
1 1 answer
341
341 views
Consider a sequence of 10 elements: $A=[2,3,-2,4,-1,0,-3,5,-4,2]$. The sequence product is defined as $P(i, j)=\prod_{k=i}^j A[k]$. Determine the maximum of $P(i, j)$, wh...
3 3 votes
2 2 answers
344
344 views
An element in an array $\mathbf{X}$ is called a Vanguard if it is greater than all elements to the left of it in $\mathbf{X}$. The first element is always a Vanguard. The...
1 1 vote
0 0 answers
317
317 views
Consider the following algorithm findCenterAlgo that takes a tree $T$ as input.findCenterAlgo (T)1. Let $T_{\text {current }}$ be a copy of the input tree $T$.2. While th...
0 0 votes
3 3 answers
498
498 views
In a directed acyclic graph (DAG) with a source vertex $s$, the quality-score of a directed path is defined to be the sum of the weights of the edges on the path. For any...
4 4 votes
3 3 answers
502
502 views
Consider the directed, weighted graph G defined by the following vertices and edges:Vertices: $\{A, B, C, D, E, F\}$Edges and Weights:$\mathrm{A} \rightarrow \mathrm{B}(4...
1 1 vote
1 1 answer
314
314 views
Consider a state space of positive integers from 1 to 100 , where the start state is 1. The successor function for a state numbered $n$ returns two states: $n * 2$ and $n...
5 5 votes
2 2 answers
576
576 views
Consider the following three functions:$f(n)=\left(\log _2 n\right)^{\log _2 n}$ $g(n)=n^{\sqrt{\log _2 n}}$ $h(n)=(\sqrt{n})$ !Which of the following statements about th...