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 36–40 of 65

Q36Syntax-directed Translation2 marksMCQ−0.67 if wrong
Consider the following grammar (that admits a series of declarations, followed by expressions) and the associated syntax directed translation (SDT) actions, given as pseudo-code

P→D∗E∗D→int ID{record that ID.lexeme is of type int}D→bool ID{record that ID.lexeme is of type bool}E→E1+E2{check that E1.type=E2.type=int;set E.type :=int}E→!E1{check that E1.type=bool; set E.type:=bool}E→ID{set E.type :=int}\begin{array}{lll} P & \rightarrow & D^* E^* \\ D & \rightarrow & \textsf{int ID} \{ \text{record that } \textsf{ID.} \text{lexeme is of type} \textsf{ int\}} \\ D & \rightarrow & \textsf{bool ID} \{ \text{record that } \textsf{ID.} \text{lexeme is of type} \textsf{ bool\}} \\ E& \rightarrow & E_1 +E_2 \{ \text{check that } E_1. \text{type}=E_2. \text{type} = \textsf{int}; \text{set } E.\text{type }:= \textsf{int} \} \\ E & \rightarrow & !E_1 \{ \text{check that } E_1. \text{type} = \textsf{bool}; \text{ set } E.\text{type} := \textsf{bool} \} \\ E & \rightarrow & \textsf{ID} \{ \text{set } E. \text{type } := \textsf{int} \} \end{array}

With respect to the above grammar, which one of the following choices is correct?

Q37Relational Algebra2 marksMCQ−0.67 if wrong
The following relation records the age of 500 employees of a company, where empNo ( indicating the employee number) is the key:

empAge(empNo‾,age)empAge(\underline{empNo},age)

Consider the following relational algebra expression:

ΠempNo(empAge⋈(age>age1)ρempNo1,age1(empAge))\Pi_{empNo}(empAge \Join_{(age \gt age1)} \rho_{empNo1,age1}(empAge))

What does the above expression generate?

Q38Sequential Circuit2 marksMCQ−0.67 if wrong
Consider a 3-bit counter, designed using T flip-flops, as shown below:
Clock Pulse TP TQ TR P Q R P' Q' R' P Q R
Assuming the initial state of the counter given by PQR as 000, what are the next three states?

Q40Recurrence Relation2 marksMCQ−0.67 if wrong
Consider the following recurrence relation.
T(n)={T(n/2)+T(2n/5)+7nif  n>01if  n=0T\left ( n \right )=\left\{\begin{array} {lcl} T(n/2)+T(2n/5)+7n & \text{if} \; n > 0\\1 & \text{if}\; n=0 \end{array}\right.
Which one of the following options is correct?