GATE 2023 Computer Science and Information Technology (CS) Questions with Solutions

GATE 2023

65 questions

MCQ 34 · MSQ 15 · NAT 161-mark 30 · 2-mark 35

Questions 36–40 of 65

Q36Function2 marksMCQ−0.67 if wrong
Consider the following program:

int main()
{
  f1();
  f2(2);
  f3();
  return(0);
}

int f1()
{
  return(1);
}

int f2(int X)
{
  f3();
  if (X==1)
     return f1();
  else
     return (X*f2(X-1));
}

int f3()
{
  return(5);
}


Which one of the following options represents the activation tree corresponding to the main function?
main f1 f2 f3 f3 f2 f3 f1 (A) main f1 f2 f3 f1 (C) main f1 f2 f3 f3 f1 (B) main f1 f2 f3 f3 f2 f1 (D)

Q37Intermediate Code Generation2 marksMCQ−0.67 if wrong
Consider the control flow graph shown.
ENTRYEXIT B1B2B3B4 i = m - 1j = na = 10i = i + 1j = j - 1a = 20i = a + 1
Which one of the following choices correctly lists the set of live variables at the exit point of each basic block?

Q38Process Synchronization2 marksMCQ−0.67 if wrong
Consider the two functions incr and decr shown below.

incr(){
  wait(s);
  X = X+1;
  signal(s);
}

decr(){
  wait(s);
  X = X-1;
  signal(s);
}

There are 5 threads each invoking incr once, and 3 threads each invoking decr once, on the same shared variable X. The initial value of X is 10.
Suppose there are two implementations of the semaphore ss, as follows:

I-1: s is a binary semaphore initialized to 1.
I-2: s is a counting semaphore initialized to 2.

Let V1, V2 be the values of X at the end of execution of all the threads with implementations I-1, I-2, respectively.
Which one of the following choices corresponds to the minimum possible values of V1, V2, respectively?

Q39Context Free Grammar2 marksMCQ−0.67 if wrong
Consider the context-free grammar GG below
S→aSb  ∣  XS\rightarrow aSb \;| \;X
X→aX  ∣  Xb  ∣  a  ∣  bX\rightarrow aX \;| \;Xb \;|\; a\;|\; b
where SS and XX are non-terminals, and aa and bb are terminal symbols. The starting non-terminal is SS.
Which one of the following statements is CORRECT?

Q40Push-down Automata2 marksMCQ−0.67 if wrong
Consider the pushdown automaton (PDA) PP below, which runs on the input alphabet {a,b}\{a,b\}, has stack alphabet {⊥,A}\{ \perp ,A\}, and has three states {s,p,q}\{s,p,q\}, with ss being the start state. A transition from state uu to state vv , labelled c/X/γc/X/\gamma , where cc is an input symbol or ϵ\epsilon, XX is a stack symbol, and γ\gamma is a string of stack symbols, represents the fact that in state uu, the PDA can read cc from the input, with XX on the top of its stack, pop XX from the stack, push in the string γ\gamma on the stack, and go to state vv. In the initial configuration, the stack has only the symbol ⊥\perp in it. The PDA accepts by empty stack.
s p q a//A a/A/AA b/A/ε b/A/ε ε/A/ε ε/A/ε ε/A/ε ε//ε
Which one of the following options correctly describes the language accepted by PP?