Algorithms questions

Q30

GATE CS 2018 CSGraph AlgorithmsMCQ2 marks−2/3 if wrong
Let GG be a simple undirected graph. Let TDT_D be a depth first search tree of GG. Let TBT_B be a breadth first search tree of GG. Consider the following statements.

(I) No edge of GG is a cross edge with respect to TDT_D. (A cross edge in GG is between two nodes neither of which is an ancestor of the other in TDT_D.)
(II) For every edge (u,v)(u, v) of GG, if uu is at depth ii and vv is at depth jj in TBT_B, then ∣i−j∣=1|i - j| = 1.

Which of the statements above must necessarily be true?
Show answer without attempting

Answer: A

Q31

GATE CS 2018 CSAlgorithm DesignMCQ2 marks−2/3 if wrong
Assume that multiplying a matrix G1G_1 of dimension p×qp \times q with another matrix G2G_2 of dimension q×rq \times r requires pqrpqr scalar multiplications. Computing the product of nn matrices G1G2G3…GnG_1 G_2 G_3 \dots G_n can be done by parenthesizing in different ways. Define GiGi+1G_i G_{i+1} as an explicitly computed pair for a given parenthesization if they are directly multiplied. For example, in the matrix multiplication chain G1G2G3G4G5G6G_1 G_2 G_3 G_4 G_5 G_6 using parenthesization (G1(G2G3))(G4(G5G6))(G_1(G_2 G_3))(G_4(G_5 G_6)), G2G3G_2 G_3 and G5G6G_5 G_6 are the only explicitly computed pairs.

Consider a matrix multiplication chain F1F2F3F4F5F_1 F_2 F_3 F_4 F_5, where matrices F1,F2,F3,F4F_1, F_2, F_3, F_4 and F5F_5 are of dimensions 2×25,25×3,3×16,16×12 \times 25, 25 \times 3, 3 \times 16, 16 \times 1 and 1×10001 \times 1000, respectively. In the parenthesization of F1F2F3F4F5F_1 F_2 F_3 F_4 F_5 that minimizes the total number of scalar multiplications, the explicitly computed pairs is/are
Show answer without attempting

Answer: C

Q47

GATE CS 2018 CSGraph AlgorithmsNAT2 marks
Consider the following undirected graph G:

Choose a value for xx that will maximize the number of minimum weight spanning trees (MWSTs) of G. The number of MWSTs of G for this value of xx is ______.
Question figure
Show answer without attempting

Answer: 4

Q48

GATE CS 2018 CSAlgorithm DesignNAT2 marks
Consider the weights and values of items listed below. Note that there is only one unit of each item.
Item numberWeight (in Kgs)Value (in Rupees)
11060
2728
3420
4224
The task is to pick a subset of these items such that their total weight is no more than 11 Kgs and their total value is maximized. Moreover, no item may be split. The total value of items picked by an optimal algorithm is denoted by VoptV_{\text{opt}}. A greedy algorithm sorts the items by their value-to-weight ratios in descending order and packs them greedily, starting from the first item in the ordered list. The total value of items picked by the greedy algorithm is denoted by VgreedyV_{\text{greedy}}.

The value of Vopt−VgreedyV_{\text{opt}} - V_{\text{greedy}} is ____________.
Show answer without attempting

Answer: 16

0/40 correct0 marks

Related topics in GATE CS