GATE 2021 (Session 1) Computer Science and Information Technology (CS) Questions with Solutions

GATE 2021 (Session 1)

65 questions

MCQ 34 · MSQ 13 · NAT 181-mark 30 · 2-mark 35

Questions 46–50 of 65

Q46Shortest Path2 marksMCQ−0.67 if wrong
Let G=(V,E)G=(V,E) be an undirected unweighted connected graph. The diameter of GG is defined as:
diam(G)=max⁡u,v∈V{the length of shortest path between u and v}diam(G)=\displaystyle \max_{u,v \in V} \{ \text{the length of shortest path between }u \text{ and }v \}

Let MM be the adjacency matrix of GG.
Define graph G2G_2 on the same set of vertices with adjacency matrix NN, where

Nij={1if  Mij>0 or Pij>0, where P=M20otherwiseN_{ij}=\left\{\begin{array} {lcl} 1 &\text{if}\; M_{ij}>0 \text{ or } P_{ij}>0, \text{ where }P=M^2\\0 &\text{otherwise} \end{array}\right.

Which one of the following statements is true?

Q47Conditional Statement2 marksMCQ−0.67 if wrong
Consider the following ANSI C program.
 #include <stdio.h>
int main()
{
    int i, j, count;
    count=0;
    i=0;
    for (j=-3; j <=3; j++)
    {
        if (( j >= 0) && (i++))
        count = count + j;
    }
    count = count +i;
    printf("%d", count);
    return 0;
}
Which one of the following options is correct?

Q48Finite Automata2 marksMCQ−0.67 if wrong
Consider the following language:

L={w∈{0,1}∗∣w ends with the substring 011}L= \{ w \in \{0,1\}^* \mid w \text{ ends with the substring } 011 \}

Which one of the following deterministic finite automata accepts LL?
(A) start 0 1 0 0 1 1 1 0 (B) start 0 1 0 0 1 1 0,1 (C) start 0 1 0 0 1 1 1 0 (D) start 0 1 0 0 1 1 1 0

Q49Turing Machine2 marksMCQ−0.67 if wrong
For a Turing machine M, < M > denotes an encoding of M. Consider the following two languages.

L1={⟨M⟩∣M takes more than 2021 steps on all inputs}L2={⟨M⟩∣M takes more than 2021 steps on some input}\begin{array}{ll} L1 = \{ \langle M \rangle \mid M \text{ takes more than } 2021 \text{ steps on all inputs} \} \\ L2 = \{ \langle M \rangle \mid M\text{ takes more than } 2021 \text{ steps on some input} \} \end{array}

Which one of the following options is correct?

Q50Greedy Technique2 marksMSQ
Define RnR_n to be the maximum amount earned by cutting a rod of length n meters into one or more pieces of integer length and selling them. For i>0i > 0, let p[i]p[i] denote the selling price of a rod whose length is ii meters. Consider the array of prices:

p[1]=1,p[2]=5,p[3]=8,p[4]=9,p[5]=10,p[6]=17,p[7]=18\text{p}[1]=1,\text{p}[2]=5,\text{p}[3]=8,\text{p}[4]=9,\text{p}[5]=10,\text{p}[6]=17,\text{p}[7]=18

which of the following statements is/are correct about R7R_7?

One or more options are correct.