Javatpoint Logo
Javatpoint Logo

GATE 2017 CS Set 1

33) Consider a combination of T and D flip-flops connected as shown below. The output of the D flipflop is connected to the input of the T flip-flop and the output of the T flip-flop is connected to the input of the D flip-flop.

Gate 2017 CS set 1

Initially, both Q0 and Q1 are set to 1 (before the 1st clock cycle). The outputs

  1. Q1 Q0 after the 3rd cycle are 11 and after the 4th cycle are 00 respectively
  2. Q1 Q0 after the 3rd cycle are 11 and after the 4th cycle are 01 respectively
  3. Q1 Q0 after the 3rd cycle are 00 and after the 4th cycle are 11 respectively
  4. Q1 Q0 after the 3rd cycle are 01 and after the 4th cycle are 01 respectively

Answer: B

Explanation:

Clock T = Q1 D = Q0 T1 = Q0 D0 = Q1
1 1 1 1
1 0 1 1 0
2 1 0 0 1
3 1 1 1 1
4 0 1 1 1

In the above table we can see that: T(Q1) and D(Q0) after the 3rd cycle are 11 and after the 4th cycle are 01. Therefore option (B) is the correct answer.


34) If G is grammar with productions

       S → SaS | aSb | bSa | SS | ∈

where S is the start variable, then which one of the following is not generated by G?

  1. abab
  2. aaab
  3. abbaa
  4. babba

Answer: D

Explanation:

Given grammar,
   S->aSb | bSa | SS | ∈
The above grammar will always produce number of a's and b's equal. Now we can generate the given options with following sequence of productions

For option a:
   S->aSb->abSab->abab

For option b:
   S->aSb->aSaSb->aSaSab->aaab

For option c:
   S->SS->aSbSaS->abbSaa->abbaa

For option d:
   It produces more number of b's than a's which surely cannot be generated by this grammar.

Therefore option (D) is the correct answer.


35) Consider the following two functions

The output printed when fun1 (5) is called is

  1. 53423122233445
  2. 53423120112233
  3. 53423122132435
  4. 53423120213243

Answer: A

Explanation:

Gate 2017 CS set 1

So, output fun1(5) = 53423122233445. Therefore option(A) is the correct answer.


36) Consider the C functions foo and bar given below:

Invocations of foo(3) and bar(3) will result in:

  1. Return of 6 and 6 respectively
  2. Infinite loop and abnormal termination respectively
  3. Abnomal termination and infinite loop respectively
  4. Both terminating abnormally

Answer: C

Explanation:

First, take foo function and according to question, the Initial value of variable val = 3. Now when foo(val--) called it returns val = 2 then, again and again, it calls foo(3) which in turn calls foo(3) and this goes on. So, here we can see that foo(3) is called an infinite number of times which causes abrupt termination.

Now, we consider a bar. In this, we can see that the val is not decrementing in the loop. So when bar(int val) called it performs like below,
   bar(3) will call bar(2)
   bar(2) will call bar(1)
   bar(1) will call bar(0)→ Here, bar(0) return0
   bar(1) will call bar(0)

So here we can see that there is a problem of an infinite loop, but it will not be terminated abruptly.

Therefore option (C) is the correct answer.


37) Consider the following context-free grammars over the alphabet {a,b,c} given below, S and T are non-terminals.

     G1: S-->aSb|T, T--> cT|∈
     G2: S-->bSa|T, T--> cT|∈

The language L1(G1) ∩ L2(G2).

  1. Finite
  2. Non-finite but regular
  3. Context-free but not regular
  4. Recursive but not context-free

Answer: B

Explanation:

The language generated by grammar G1 is,
   L(G1) = ancbn | n≥0

The language generated by grammar G2 is,
   L(G2) = bncan | n≥0

The intersection of two languages will be,
   L(G1)∩L(G2) = c∗

We know that c* is a regular language and infinite. Therefore option (B) will bw the correct answer..


38) Consider the following languages over the alphabet ∑ = {a,b,c}. Let L1 = {anbncm | m, n >= 0} and L2 = {ambncn| m, n >= 0}.

Which of the following are context-free languages ?

   (I) L1 ∪ L2
   (II) L1 ∩ L2

  1. I only
  2. II only
  3. I and II
  4. Neither I nor II

Answer: A

Explanation:

Given,
L1 = {anbncm | m, n >= 0} and
L2 = {ambncn| m, n >= 0}

We know that union of context free language is also context free language.

So, L3 = L1 ∪ L2 = { anbncm ∪ ambncn | n, m >= 0 } is also context free.

Since, In L1: number of a's = number of b's and In L2: number of b's = number of c's. Therefore, their union is also a context free language. So it is true.

Intersection of context free language may or may not be context free language.

L3 = L1 ∩ L2 = {anbncn| n >= 0} can not be context free language.

Therefore option (A) will be the correct answer.


39) Let A and B be infinite alphabets and let # be a symbol outside both A and B. Let f be a total functional from A* to B*.We say f is computable if there exists a Turning machine M which given an input x in A*, always halts with f(x) on its tape. Let Lf denotes the language {x#f(x)|x∈A*}. Which of the following statements is true?

  1. f if computable if and only if Lf is recursive.
  2. f if computable if and only if Lf is recursive enumerable.
  3. if f is computable then Lf is recursive, but not conversely.
  4. if f is computable then Lf is recursively enumerable, but not conversely.

Answer: A

Explanation:

According to the definition which is given as Halting of Turing Machine, i.e. Every recursive language is computable, but converse may not be true.

Therefore option (A) will be the correct answer.


40) Recall that Belady's anomaly is that the pages-fault rate may increase as the number of allocated frames increases. Now consider the following statements:

S1: Random page replacement algorithm (where a page chosen at random is replaced) suffers from Belady's anomaly.
S2: LRU page replacement algorithm suffers from Belady's anomaly.

Which of the following is CORRECT?

  1. S1 is true, S2 is true
  2. S1 is true, S2 is false
  3. S1 is false, S2 is true
  4. S1 is false, S2 is false

Answer: B

Explanation:

As per rule, the page replacement algorithm suffers from Belady's anamoly when it is not a stack algorithm. A stack algorithm is that which satisfies the inclusion property. The inclusion property is the set of pages in a k-frame memory is always a subset of the pages in a (k + 1) frame memory.

In statement S1: Random page replacement algorithm may choose a page to replace in FIFO manner or in a manner which does not satisfy inclusion property. So, it could suffer from Belady's anamoly.

In statement S2: LRU is a stack algorithm. So, it doesn't suffer from Belady's anamoly.

Therefore option (B) is the correct answer.


GATE 2017 CS Set 1-1
GATE 2017 CS Set 1-2
GATE 2017 CS Set 1-3
GATE 2017 CS Set 1-4
GATE 2017 CS Set 1-6
GATE 2017 CS Set 1-7
GATE 2017 CS Set 1-8






Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA