GATE 2024 (Session 2) Computer Science and Information Technology (CS) Questions with Solutions

GATE 2024 (Session 2)

65 questions

MCQ 32 · MSQ 18 · NAT 151-mark 30 · 2-mark 35

Questions 41–45 of 65

Q41Regular Expression2 marksMCQ−0.67 if wrong
Let M be the 5-state NFA with ϵ\epsilon-transitions shown in the diagram below:
12345 εε00ε11
Which one of the following regular expressions represents the language accepted by M ?

Q42Array and Pointer2 marksMCQ−0.67 if wrong
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 labelled (P) and (Q).

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 = (P) ;
		second = first;
	 } else {
		len2 = (Q) ;
		len1 = 1; second = first;
	 }
	 if (len2 > maxlen) {
		maxlen = len2;
	}
	  first = X[i];
}
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.)

Q43Intermediate Code Generation2 marksMCQ−0.67 if wrong
Consider the following expression: x[i]=(p+r)∗−s[i]+u/wx[i]=(p+r) *-s[i]+u / w. The following sequence shows the list of triples representing the given expression, with entries missing for triples (1), (3), and (6).
(0)+pr(1)(2)uminus(1)(3)(4)/uw(5)+(3)(4)(6)(7)=(6)(5)\begin{array}{|c|c|c|c|} \hline (0) & + & p & r \\ \hline (1) & & & \\ \hline (2) & uminus & (1) & \\ \hline (3) & & & \\ \hline (4) & / & u & w \\ \hline (5) & + & (3) & (4) \\ \hline (6) & & & \\ \hline (7) & = & (6) & (5) \\ \hline \end{array}
Which one of the following options fills in the missing entries CORRECTLY?

Q44Random Variables and Distributions2 marksMCQ−0.67 if wrong
Let xx and yy be random variables, not necessarily independent, that take real values in the interval [0,1][0,1]. Let z=xyz=x y and let the mean values of x,y,zx, y, z be xˉ,yˉ,zˉ\bar{x}, \bar{y}, \bar{z}, respectively. Which one of the following statements is TRUE?

Q45Relational Algebra2 marksMCQ−0.67 if wrong
The relation schema, Person(pid,city), describes the city of residence for every person uniquely identified by pid. The following relational algebra operators are available: selection, projection, cross product, and rename.

To find the list of cities where at least 3 persons reside, using the above operators, the minimum number of cross product operations that must be used is