GATE 2021 (Session 1)
65 questions
MCQ 34 · MSQ 13 · NAT 181-mark 30 · 2-mark 35
Questions 46–50 of 65
Let be an undirected unweighted connected graph. The diameter of is defined as:
Let be the adjacency matrix of .
Define graph on the same set of vertices with adjacency matrix , where
Which one of the following statements is true?
Let be the adjacency matrix of .
Define graph on the same set of vertices with adjacency matrix , where
Which one of the following statements is true?
Answer: (A)
means there is a walk of length 2 from to . So in two vertices are adjacent when their distance in is 1 or 2.
Upper bound. Take a shortest path of length in and jump two edges at a time. This reaches the end in edges of .
Lower bound. Each edge of spans at most 2 edges of , so edges of cover a distance of at most in .
So the distance in is exactly , and .
So option (A) is true. Options (B), (C) and (D) each need to be larger than , which does not happen.
Answer: (A)
Upper bound. Take a shortest path of length in and jump two edges at a time. This reaches the end in edges of .
Lower bound. Each edge of spans at most 2 edges of , so edges of cover a distance of at most in .
So the distance in is exactly , and .
So option (A) is true. Options (B), (C) and (D) each need to be larger than , which does not happen.
Answer: (A)
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?Answer: (B)
(The loop goes from j = 3 up to 3, and the program compiles.) When j 0, the && stops early, so i++ is not run.
When j 0, i++ gives the old value of i:
- j = 0: i++ gives 0 (false), then i = 1
- j = 1: it gives 1 (true), count = 1, i = 2
- j = 2: count = 3, i = 3
- j = 3: count = 6, i = 4
Finally, count = 6 + i = 6 + 4 = 10
Answer: The program will compile successfully and output 10 when executed
When j 0, i++ gives the old value of i:
- j = 0: i++ gives 0 (false), then i = 1
- j = 1: it gives 1 (true), count = 1, i = 2
- j = 2: count = 3, i = 3
- j = 3: count = 6, i = 4
Finally, count = 6 + i = 6 + 4 = 10
Answer: The program will compile successfully and output 10 when executed
Consider the following language:
Which one of the following deterministic finite automata accepts ?
Which one of the following deterministic finite automata accepts ?
Answer: (D)
Each state must remember the longest suffix that matches a prefix of 011. The states are q0 (nothing), q1 ("0"), q2 ("01") and q3 ("011", the final state).
Transitions out of the final state: on 0 it goes q1 (suffix "0"). On 1 it goes q0 (the suffix "0111" has no useful part).
- (A) and (B) loop on 1 at the final state, so they accept 0111. False
- (C) moves from the final state to q2 on 1, so it accepts 01111. False
- (D) has exactly the transitions given above. True
Answer: D
Transitions out of the final state: on 0 it goes q1 (suffix "0"). On 1 it goes q0 (the suffix "0111" has no useful part).
- (A) and (B) loop on 1 at the final state, so they accept 0111. False
- (C) moves from the final state to q2 on 1, so it accepts 01111. False
- (D) has exactly the transitions given above. True
Answer: D
For a Turing machine M, < M > denotes an encoding of M. Consider the following two languages.
Which one of the following options is correct?
Which one of the following options is correct?
Answer: (A)
M can read only the first 2021 input symbols within 2021 steps. So whether M takes more than 2021 steps depends only on inputs of length at most 2021. These inputs are a finite set.
Run M for 2022 steps on each of these inputs. This check decides L1 (all inputs) and also L2 (some input).
Answer: Both L1 and L2 are decidable
Run M for 2022 steps on each of these inputs. This check decides L1 (all inputs) and also L2 (some input).
Answer: Both L1 and L2 are decidable
Define 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 , let denote the selling price of a rod whose length is meters. Consider the array of prices:
which of the following statements is/are correct about ?
which of the following statements is/are correct about ?
One or more options are correct.
Answer: (A), (C)
Let be the best value for length . Then .
, , , , , .
.
Checking all ways to cut 7 shows exactly three reach 18:
- one piece of 7 (18)
- 6 + 1 (17 + 1)
- 3 + 2 + 2 (8 + 5 + 5)
Every other split gives at most 17 (for example 4 + 3 gives 17, and 3 + 3 + 1 gives 17).
(A) is true: . (B) is false, since 19 is never reached. (C) is true: there are three different solutions. (D) is false, since 3 + 2 + 2 uses three pieces and gives 18.
Answer: (A), (C)
, , , , , .
.
Checking all ways to cut 7 shows exactly three reach 18:
- one piece of 7 (18)
- 6 + 1 (17 + 1)
- 3 + 2 + 2 (8 + 5 + 5)
Every other split gives at most 17 (for example 4 + 3 gives 17, and 3 + 3 + 1 gives 17).
(A) is true: . (B) is false, since 19 is never reached. (C) is true: there are three different solutions. (D) is false, since 3 + 2 + 2 uses three pieces and gives 18.
Answer: (A), (C)