GATE CSE 2024 | Set 2

Last Updated :
Discuss
Comments

Question 1

Let G be an undirected connected graph in which every edge has a positive integer weight. Suppose that every spanning tree in G has an even weight. Which of the following statements is/are TRUE for every such graph G?

  • All edges in G have even weight

  • All edges in G have even weight OR all edges in G have odd weight

  • In each cycle C in G, all edges in C have even weight

  • In each cycle C in G, either all edges in n 𝐶 have even weight OR all edges in C have odd weight.

Question 2

Which of the following statements is/are FALSE?

  • An attribute grammar is a syntax-directed definition (SDD) in which the functions in the semantic rules have no side effects

  • The attributes in a L-attributed definition cannot always be evaluated in a depth-first order

  • Synthesized attributes can be evaluated by a bottom-up parser as the input is parsed

  • All L-attributed definitions based on LR(1) grammar can be evaluated using a bottom-up parsing strategy

Question 3

For a Boolean variable x, which of the following statements is/are FALSE?

  • x . 1 = x

  • x + 1 = x

  • x . x = 0

  • x + x' = 1

Question 4

Consider the following C function definition.

int fX(char *a){
char *b = a;
while(*b)
b++;
return b - a;}

Which of the following statements is/are TRUE?

  • The function call fX(”abcd”) will always return a value

  • Assuming a character array c is declared as char c[] = ”abcd” in main(), the function call fX(c)will always return a value

  • The code of the function will not compile

  • Assuming a character pointer c is declared as char *c = ”abcd” in main(), the function call fX(c)will always return a value

Question 5

Let P be the partial order defined on the set {1,2,3,4} as follows P = {(x, x) | x ∈ {1,2,3,4}} ∪ {(1,2), (3,2), (3,4)}. The number of total orders on {1,2,3,4} that contain P is __________

  • 4

  • 3

  • 2

  • 5

Question 6

Consider a single processor system with four processes A, B, C, and D, represented as given below, where for each process the first value is its arrival time, and the second value is its CPU burst time.
A (0, 10), B (2, 6), C (4, 3), and D (6, 7).
Which one of the following options gives the average waiting times when preemptive Shortest Remaining Time First (SRTF) and Non-Preemptive Shortest Job First (NP-SJF) CPU scheduling algorithms are applied to the processes?

  • SRTF = 6, NP-SJF = 7

  • SRTF = 6, NP-SJF = 7.5

  • SRTF = 7, NP-SJF = 7.5

  • SRTF = 7, NP-SJF = 8.5

Question 7

You are given a set V of distinct integers. A binary search tree T is created by inserting all elements of V one by one, starting with an empty tree. The tree T follows the convention that, at each node, all values stored in the left subtree of the node are smaller than the value stored at the node. You are not aware of the sequence in which these values were inserted into T, and you do not have access to T. 

Which one of the following statements is TRUE?

  • In order traversal of T can be determined from V

  • The root node of T can be determined from V

  • Preorder traversal of T can be determined from V

  • Postorder traversal of T can be determined from V

Question 8

Consider the following context-free grammar where the start symbol is S and the set of terminals is {a,b,c,d}.

S -> AaAb | BbBa

A -> cS | ∈

B -> dS | ∈

The following is a partially filled LL(1) parsing table.

 abcd$
SS -> AaAbS -> BbBa(1)(2) 
AA -> ∈(3)A -> cS  
B(4)B -> ∈ B -> dS 

Which one of the following options represents the CORRECT combination for the numbered cells in the parsing table?

Note: In the options, "blank" denotes that the corresponding cell is empty.

  • (1) S -> AaAb (2) S -> BbBa (3) A -> ∈ (4) B -> ∈

  • (1) S -> BbBa (2) S -> AaAb (3) A -> ∈ (4) B -> ∈

  • (1) S -> AaAb (2) S -> BbBa (3) blank (4) blank

  • (1) S -> BbBa (2) S -> AaAb (3) blank (4) blank

Question 9

Let M be the 5-state NFA with ∈-transitions shown in the diagram below.

 

Which one of the following regular expressions represents the language accepted by M?

  • (00)* + 1(11)*

  • 0* + (1 + 0(00)*)(11)*

  • (00)* + (1 + (00)*)(11)*

  • 0+ + 1(11)* + 0(11)*

Question 10

Consider an array X that contains n positive integers. A subarray of X is defined to be a sequence of array locations with consecutive indices.

The C code snippet given below has been written to compute the length of the longest subarray of X that contains at most two distinct integers. The code has two missing expressions labeled (P) and (Q).

Which one of the following options gives the CORRECT missing expressions?

(Hint: At the end of the i-th iteration, the value of len1 is the length of the longest subarray ending with X[i] that contains all equal values, and len2 is the length of the longest subarray ending with X[i] that contains at most two distinct values.)

int first=0, second=0, len1=0, len2=0, maxlen=0; 
for (int i=0; i < n; i++) {
if (X[i] == first) {
len2++; len1++;
} else if (X[i] == second) {
len2++;
len1 = (𝑃) ;
second = first;
} else {
len2 = (𝑄) ;
len1 = 1;
second = first;
} if (len2 > maxlen) {
maxlen = len2;
} first = X[i];
}
  • (P) len1 + 1     (Q) len2 + 1

  • (P) 1      (Q) len1 + 1

  • (P) 1       (Q) len2 + 1

  • (P) len2 + 1      (Q) len1 + 1

There are 65 questions to complete.

Take a part in the ongoing discussion