GATE 2026 (Session 2)
65 questions
MCQ 35 · MSQ 11 · NAT 191-mark 30 · 2-mark 35
Questions 36–40 of 65
Consider a complete graph with vertices ( ). Note that multiple spanning trees can be constructed over . Each of these spanning trees is represented as a set of edges. The Jaccard coefficient between any two sets is defined as the ratio of the size of the intersection of the two sets to the size of the union of the two sets.
Which one of the following options gives the lowest possible value for the Jaccard coefficient between any two spanning trees of ?
Which one of the following options gives the lowest possible value for the Jaccard coefficient between any two spanning trees of ?
Answer: (C)
The Jaccard coefficient of two edge sets is . It is never negative, and it is exactly when the two trees have no common edge. So the lowest value is if has two edge-disjoint spanning trees.
It does. Number the vertices .
- : the path , with edges .
- : the edges for , plus the edge . This is a star on vertices with vertex 2 attached to vertex 4. It has edges and is connected, so it is a spanning tree.
No edge with and not the edge has the form , so and share no edge.
So the intersection is empty, the union has edges, and the coefficient is . The other options are all positive, so they are not the lowest.
Answer: (C)
It does. Number the vertices .
- : the path , with edges .
- : the edges for , plus the edge . This is a star on vertices with vertex 2 attached to vertex 4. It has edges and is connected, so it is a spanning tree.
No edge with and not the edge has the form , so and share no edge.
So the intersection is empty, the union has edges, and the coefficient is . The other options are all positive, so they are not the lowest.
Answer: (C)
Let be a weighted directed acyclic graph with edges and vertices. Given and a source vertex in , which one of the following options gives the worst case time complexity of the fastest algorithm to find the lengths of shortest paths from to all vertices that are reachable from in
Answer: (A)
For a directed acyclic graph (DAG) the fastest method has two steps.
(1) Find a topological order of the vertices: .
(2) Take the vertices in that order and relax each outgoing edge of each vertex once: in total.
This is correct because in topological order every edge into a vertex has been relaxed before that vertex is processed, so its distance is already final. So no priority queue and no repeated passes are needed, and negative edge weights cause no trouble.
Option (B) is Dijkstra's bound with a priority queue, which is never faster than . Option (C) is the Bellman-Ford bound. Option (D) is the all-pairs Floyd-Warshall bound.
Answer: (A)
(1) Find a topological order of the vertices: .
(2) Take the vertices in that order and relax each outgoing edge of each vertex once: in total.
This is correct because in topological order every edge into a vertex has been relaxed before that vertex is processed, so its distance is already final. So no priority queue and no repeated passes are needed, and negative edge weights cause no trouble.
Option (B) is Dijkstra's bound with a priority queue, which is never faster than . Option (C) is the Bellman-Ford bound. Option (D) is the all-pairs Floyd-Warshall bound.
Answer: (A)
Consider an array of integers of size . The indices of run from to . An algorithm is to be designed to check whether satisfies the condition given below.
such that
Which one of the following gives the worst case time complexity of the fastest algorithm that can be designed for the problem?
such that
Which one of the following gives the worst case time complexity of the fastest algorithm that can be designed for the problem?
Answer: (A)
The condition applies to every pair of indices , with both indices in . The difference must be larger than . So the list of consecutive differences has to be strictly increasing. This means the array is "convex".
One pass over the array is enough to check this. Compute each and test for every consecutive pair. Stop at once and answer "no" the first time a test fails. This takes time. It is also optimal, because every element of the array must be looked at at least once to confirm the condition.
Answer:
One pass over the array is enough to check this. Compute each and test for every consecutive pair. Stop at once and answer "no" the first time a test fails. This takes time. It is also optimal, because every element of the array must be looked at at least once to confirm the condition.
Answer:
Consider a table , where the elements , represent the cost of the optimal solutions of different subproblems of a problem that is being solved using a dynamic programming algorithm. The recursive formulation to compute the table entries is as follows:
Consider the following two algorithms to compute entries of . Assume that for both the algorithms, for all has been initialized to .
Algorithm is said to be correct if and only if it calculates the correct values of , for all , (as per the recursive formulation) at the end of the execution of the algorithm .
Which one of the following statements is true?
Consider the following two algorithms to compute entries of . Assume that for both the algorithms, for all has been initialized to .
Algorithm is said to be correct if and only if it calculates the correct values of , for all , (as per the recursive formulation) at the end of the execution of the algorithm .
Which one of the following statements is true?
Answer: (A)
To correctly compute , both dependencies — (the cell directly above) and (the cell directly to the left) — must already hold their final, correct values before is computed.
Algorithm B1 (row-major: outer loop over , inner over ): when computing , was already finalized in the previous (fully completed) row, and was already finalized earlier in the same row (since and the inner loop moves left-to-right). Both dependencies are satisfied in time. Correct.
Algorithm B2 (processes cells in order of increasing anti-diagonal ): for a cell with , its dependency lies on diagonal and also lies on diagonal — both are processed in the strictly earlier iteration (all cells of a smaller diagonal are done before any cell of a larger diagonal begins). Both dependencies are also satisfied in time. Correct.
Answer: Both algorithms B1 and B2 are correct.
Algorithm B1 (row-major: outer loop over , inner over ): when computing , was already finalized in the previous (fully completed) row, and was already finalized earlier in the same row (since and the inner loop moves left-to-right). Both dependencies are satisfied in time. Correct.
Algorithm B2 (processes cells in order of increasing anti-diagonal ): for a cell with , its dependency lies on diagonal and also lies on diagonal — both are processed in the strictly earlier iteration (all cells of a smaller diagonal are done before any cell of a larger diagonal begins). Both dependencies are also satisfied in time. Correct.
Answer: Both algorithms B1 and B2 are correct.
Consider the following -variable Boolean function
Consider as MSB, as LSB. Which one of the following options represents the minimal sum of products form for the above function?
Note: is OR operation, is AND operation, is NOT operation
Consider as MSB, as LSB. Which one of the following options represents the minimal sum of products form for the above function?
Note: is OR operation, is AND operation, is NOT operation
Answer: (B)
Write each minterm in binary. The bit order is : .
Look at all minterms. The bit is in every one of them. The variables take both values, so they cover all combinations. This is exactly the full set of minterms with , whatever the values of .
So the function reduces to one literal: . Its minimal SOP form has just one term.
Answer: B′
Look at all minterms. The bit is in every one of them. The variables take both values, so they cover all combinations. This is exactly the full set of minterms with , whatever the values of .
So the function reduces to one literal: . Its minimal SOP form has just one term.
Answer: B′