PREVIOUS YEAR SOLVED PAPERS - GATE 2018

31. Consider the following parse tree for the expression a#b$c$d#e#f, involving two binary operators $ and #.

  • Option : A
  • Explanation :
    here $ is higher precedence than # $ is left associative because in the sub expression b $ c $ d, b $ c will be evaluated first as per given tree.
    As per the given tree structure right # if higher precedence than left #.
    Hence it is right associative.
Cancel reply

Your email address will not be published. Required fields are marked *


Cancel reply

Your email address will not be published. Required fields are marked *


32. 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{
  wait(p);
  wait(mutex);
  //Add item to buffer
  signal(mutex);
  signal(Q);
}while (1);
 do{
  wait(R);
  wait(mutex);
  //Consume item from buffer
  signal (mutex);
  signal ();
}while (1);
 Which one of the following assignments to P, Q, R and S will yield the correct solution?

  • Option : C
  • Explanation :
    Full = N, empty = 0, mutex = 1
    Initially buffer will be empty, so consumer should not start first, so options B, D are eliminated.
    With option A consumer will never consume the item, so it is wrong.
    Option ‘C’ is the correct answer which proper functionality of produce and consumer.
Cancel reply

Your email address will not be published. Required fields are marked *


Cancel reply

Your email address will not be published. Required fields are marked *


33. A lexical analyzer uses the following patterns to recognize three tokens T1, T2, and T3 over the alphabet {a,b,c}.
T1: a?(b∣c)*a
T2: b?(a∣c)*b
T3: 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?

  • Option : D
  • Explanation : T3T3 because from first T3 bbaac is taken from second T3 abc is taken longest possible prefix. Hence T3T3 token output.
Cancel reply

Your email address will not be published. Required fields are marked *


Cancel reply

Your email address will not be published. Required fields are marked *


34. Consider the unsigned 8-bit fixed point binary number representation, below,
b7b6b5b4b3 ⋅ b2b1b0
Where the position of the binary point is between b3 and b2 Assume b7 is the most significant bit. Some of the decimal numbers listed below cannot be represented exactly in the above representation:
i. 31.500       ii. 0.875
iii. 12.100       iv. 3.001
Which one of the following statements is true?

  • Option : C
  • Explanation :
    Binary code: (b7b6b5b4b3 ⋅ b2b1b0)2
    (31.5)10 = (11111.1)2
    (0.875)10 = (0.111)2
    (12.100)10 = (01100.000110.....)2
              ↓
           Only 3 bits of fraction
           space available
           So can't be stored.
    (3.001)10 = (00011.000000..........)2
    It is also not accurate storage.
Cancel reply

Your email address will not be published. Required fields are marked *


Cancel reply

Your email address will not be published. Required fields are marked *


35. Let N be the set of natural numbers. Consider the following sets:
P. Set of rational numbers (positive and negative).
Q. Set of functions from {0, 1} to N.
R. Set of functions from N to {0, 1}.
S. Set of finite subsets of N.
Which of the sets above are countable?

  • Option : D
  • Explanation :
    P : Set of rational number → countable
    Q : Set of functions from {0, 1} to N → N

    0 can be assigned in N ways
    1 can be assigned in N ways
    There are functions, cross product of countable set in countable.
    R : Set of functions from N to {0, 1}

    Each of thus boxes can be assigned to 0 or 1 so each such function is a binary number with infinite number of bits.
Cancel reply

Your email address will not be published. Required fields are marked *


Cancel reply

Your email address will not be published. Required fields are marked *


Related Quiz.
GATE 2018