Javatpoint Logo
Javatpoint Logo

GATE 2017 CS Set 2

33) A system shares 9 tape drives. The current allocation and maximum requirement of tape drives for 3 processes are shown below:

Process Current Allocation Maximum Requirement
P1 3 7
P2 1 6
P3 3 5

Which of the following best describes the current state of the system?

  1. Safe, Deadlocked
  2. Safe, Not Deadlocked
  3. Not Safe, Deadlocked
  4. Not Safe, Not Deadlocked

Answer: B

Explanation:

Given, Total Tape Drive = 9

Process Current Allocation Maximum Requirement Need
P1 3 7 4
P2 1 6 5
P3 3 5 2

In the table, we can see that the currently allocated Tape Drive = 7

So, available Tape Drive is: 9 - 7 = 2

Now first we allocate the remaining Tape Drive to process P3 Which need is 2. After executing it releases 3 Tape Drive. So new available Tape Drive is: 3 + 2 = 5

Then Process P1 needs 4 Tape Drive. So it will be executed next and releases3 Tape Drive. So new available Tape Drive is: 3 + 5 = 8.

In last, Process P2 will be executed. Hence, all the Process in the Safe State with No Deadlock. Safe Thus, Safe Sequence will be P3→P2→P1 or P3→P1→P2. Therefore option (B) will be the right answer.


34) Consider a binary code that consists only four valid codewords as given below.

00000, 01011, 10101, 11110

Let minimum Hamming distance of code be p and maximum number of erroneous bits that can be corrected by the code be q. The value of p and q are:

  1. p = 3 and q = 1
  2. p = 3 and q = 2
  3. p = 4 and q = 1
  4. p = 4 and q = 2

Answer: A

Explanation:

Given,
   Code1 = 00000, Code2 = 01011, Code3 = 10101, Code4 = 11110
Hamming distance -> The number of places between two vectors will differ.

Minimum of all hamming distances is = 3 ( Code1 = 00000, and Code2 = 01011 )
So, p = 3
Now, to find the maximum number of erroneous bits that can be corrected by the code we need Hamming Distance = 2d + 1
So, 2d + 1 = 3
   d = 1

Therefore option (A) is the right answer.


35) Consider two hosts X and Y, connected by a single direct link of rate 106 bits/sec. The distance between the two hosts is 10,000 km and the propagation speed along the link is 2 x 108 m/s. Hosts X send a file of 50,000 bytes as one large message to hosts Y continuously. Let the transmission and propagation delays be p milliseconds and q milliseconds, respectively. Then the vales of p and q are:

  1. p = 50 and q = 100
  2. p = 50 and q = 400
  3. p = 100 and q = 50
  4. p = 400 and q = 50

Answer: D

Explanation:

Given,
   Bandwidth(B) = 106 bits/sec
   Distance(D) = 10000 km = 10,000,000 m = 107 m
   Propogation Speed(V) = 2 * 108 m/s
   Data Length(L) = 50, 000 Bytes = 50,000 * 8 bits
∴ Transmission Time (p) = L / B
         = (50, 000 * 8 ) / 106
         = 40 / 100 = 0.4 = 400 msec
∴ Propogation Time (q) = D / V
         = 107 / (2 * 108)
         = 1 / 20 = 0.05 = 50 msec
Therefore option (D) is the right answer.


36) The pre-order traversal of a binary search tree is given by 12, 8, 6, 2, 7, 9, 10, 16, 15, 19, 17, 20. Then the post-order traversal of this tree is:

  1. 2, 6, 7, 8, 9, 10, 12, 15, 16, 17, 19, 20
  2. 2, 7, 6, 10, 9, 8, 15, 17, 20, 19, 16, 12
  3. 7, 2, 6, 8, 9, 10, 20, 17, 19, 15, 16, 12
  4. 7, 6, 2, 10, 9, 8, 15, 16, 17, 20, 19, 12

Answer: B

Explanation:

Given,

Pre-order: 12, 8, 6, 2, 7, 9, 10, 16, 15, 19, 17, 20

In BST the first node of a pre-order traversal is always the root node. The BST will always be given in ascending order. So the corresponding Binary tree is given below-

Gate 2017 CS set 2

∴ Post-order Traversal: 2, 7, 6, 10, 9, 8, 15, 17, 20, 19, 16, 12

Therefore option (B) is the right answer.


37) Consider the C program fragment below which is meant to divide x by y using repeated subtractions. The variable x, y, q and r are all unsigned int.

Which of the following conditions on the variables x, y, q and r before the execution of the fragment will ensure that the loop terminates in a state satisfying the condition x == (y*q + r)?

  1. ( q == r ) && ( r == 0)
  2. ( x > 0 ) && ( r == x ) && ( y > 0 )
  3. ( q == 0 ) && ( r == x ) && ( y > 0 )
  4. ( q == 0 ) && ( y > 0 )

Answer: C

Explanation:

Given, x = = (y * q + r)

According to question x= product, y= Multiplicand, q= Quotient and r= Remainder

Now, to divide a number with repeated subtraction, the quotient should be 0, and it should be incremented for each subtraction. Thus, if q = 0, r = x. Therefore option (C) will be the right answer.


38) Consider the following C function.

Time complexity of fun in terms of θ notation is:

  1. θ(n √n)
  2. θ(n2)
  3. θ(n log n)
  4. θ(n2 log n)

Answer: C

Explanation:

In the above question, we have to check how many times the innermost statement printf("%d %d," i, j); of inner for loop is executed. The inner for loop is dependent on i. So,

For i=1, the statement runs n times. Thus for ith iteration, statement runs θ(n/i) times.

Hence, Time complexity of fun in terms of θ notation is:

n- 1/1 + n-1/2 + n-1/3 +...........+ n-1/n-1 +1
n/1+n/2+n/3+......+n/n-1 -log(n-1)
n{1/1+1/2+1/3+.....+1/n-1}-log(n-1)
nlog(n-1)-log(n-1)
nlog(n-1)
nlogn
Therefore option (C) will be the right answer.


39) Let δ denote the transition function and α denoted the extended transition function of the ?-NFA whose transition table is given below:

δ ε a b
?>q0 {q2} {q1} {q0}
q1 {q2} {q2} (q3}
q2 {q0) ø ø
q3 ø ø (q2}

Then, α (q2,aba) is

  1. ø
  2. {q1, q2, q3}
  3. {q0, q1, q2}
  4. {q0, q2, q3}

Answer: C

Explanation:

Given, α (q2,aba)
So, starting state is: q2
First find Epsilon closure of q2 = {q2,q0}
Then, Find transition on 'a': q0------------->q1
             q2------------->'Ø ' (i.e nothing)
Find epsilon closure of 'q1'= {q1,q2,q0}
Then, Find transition on 'b': q1------------->q3
             q0------------->q0
             q2------------->'Ø '
Now, Find epsilon closure of 'q0': {q0,q2} and epsilon closure of 'q3': {q3}
Find epsilon closure of 'q0' Union 'q3': {q3}
Then, Find transition on 'a': q0------------->q1
             q2------------->'Ø '
             q3------------->'Ø '
Again, Find epsilon closure of 'q1': {q1,q0,q2}

Therefore option (C) is the right answer.


40) Consider the following languages.

L1 = {ap | p is a prime number}
L2 = {anbmc2m | n >= 0, m >= 0}
L3 = {anbnc2n | n >= 0}
L4 = {anbn | n >= 1}

Which of the following are CORRECT ?

I. L1 is context free but not regular.
II. L2 is not context free.
III. L3 is not context free but recursive
IV. L4 is deterministic context free

  1. I, II and IV only
  2. II and III only
  3. I and IV only
  4. III and IV only

Answer: D

Explanation:

L1 is Context Sensitive Language.

L2 is Context Free Language

In L3 it is not sure when to pop b and push a, because here the comparison is performed between three consecutive terminals. So it is not a Context Free Language. Since given language is CFL, so it is recursive also.

L4 is Deterministic Context Free Language because we are sure to push a into stack first and on seeing b we are sure to pop a from the stack.

Therefore option (D) is the right answer.


GATE 2017 CS Set 2-1
GATE 2017 CS Set 2-2
GATE 2017 CS Set 2-3
GATE 2017 CS Set 2-4
GATE 2017 CS Set 2-6
GATE 2017 CS Set 2-7
GATE 2017 CS Set 2-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