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

GATE 2018

65 questions

MCQ 41 · NAT 241-mark 30 · 2-mark 35

Questions 46–50 of 65

Q46Turing Machine2 marksMCQ−0.67 if wrong
Consider the following problems. L(G) denotes the language generated by a grammar G. L(M) denotes the language accepted by a machine M.

(I) For an unrestricted grammar G and a string w, whether w∈\inL(G)
(II) Given a Turing machine M, whether L(M) is regular
(III) Given two grammars G1 and G2, whether L(G1) = L(G2)
(IV) Given an NFA N, whether there is a deterministic PDA P such that N and P accept the same language.

Which one of the following statements is correct?

Q47Lexical Analysis2 marksMCQ−0.67 if wrong
A lexical analyzer uses the following patterns to recognize three tokens T1,T2,  and  T3T_{1}, T_{2}, \; and \; T_{3} over the alphabet {a,b,c}.

T1:a?(b∣c)∗aT_{1}:a?(b|c)^* a
T2:b?(a∣c)∗bT_{2}:b?(a|c)^* b
T3:c?(b∣a)∗cT_{3}:c?(b|a)^* c

Note that 'x?' means 0 or 1 occurrence of the symbol x. Note also that the analyzer outputs the token that matches the longest possible prefix.

If the string bbaacabc is processed by the analyzer, which one of the following is the sequence of tokens it outputs?

Q48Parsing2 marksMCQ−0.67 if wrong
C onsider the following parse tree for the expression a#b$c$d#e#f, involving two binary operators $ and #.
# a # $ # $ d e f b c
Which one of the following is correct for the given parse tree?

Q49Deadlock2 marksMCQ−0.67 if wrong
In a system, there are three types of resources: E, F and G. Four processes P0,P1,P2  and  P3P_0,P_1,P_2 \; and \; P_3 execute concurrently. At the outset, the processes have declared their maximum resource requirements using a matrix named Max as given below. For example, Max[P2P_2,F] is the maximum number of instances of F that P2P_2 would require. The number of instances of the resources allocated to the various processes at any given state is given by a matrix named Allocation.
Consider a state of the system with the Allocation matrix as shown below, and in which 3 instances of E and 3 instances of F are the only resources available.
Allocation E F G P0 1 0 1 P1 1 1 2 P2 1 0 3 P3 2 0 0 Max E F G P0 4 3 1 P1 2 1 4 P2 1 3 3 P3 5 4 1
From the perspective of deadlock avoidance, which one of the following is true?

Q50Process Synchronization2 marksMCQ−0.67 if wrong
Consider the following solution to the producer-consumer synchronization problem. The shared buffer size is N. Three semaphores empty, full and mutex are defined with respective initial values of 0, N and 1. Semaphore empty denotes the number of available slots in the buffer, for the consumer to read from. Semaphore full denotes the number of available slots in the buffer, for the producer to write to. The placeholder variables, denoted by P, Q, R, and S, in the code below can be assigned either empty or full. The valid semaphore operations are: wait() and signal().
Producer:                   Consumer:

do{                         do{
    wait(P);                    wait(R);
    wait(mutex);                wait(mutex);
    //Add item to buffer        //Consume item from buffer
    signal(mutex);              signal(mutex);
    signal(Q);                  signal(S);
}while(1);                  }while(1);

Which one of the following assignments to P, Q, R and S will yield the correct solution?