Javatpoint Logo
Javatpoint Logo

GATE 2016 CS Set 2

17) Consider an eight-bit ripple-carry adder for computing the sum of A and B, where A and B are integers represented in 2's complement form. If the decimal value of A is one, the decimal value of B that leads to the longest latency for the sum to stabilize is ______________.

  1. 1
  2. 0
  3. -0.5
  4. -1

Answer: D

Explanation:

Given, the decimal value of A = 1
If it is in 8-bit representation, then 1 can be written as: 00000001
And its 2's complement = 11111111
The 2's complement has a sign bit 1 which is negative so it will take one extra gate. Hence answer should be -1.
Therefore option (D) is the right answer.


18) Let, x1 ⊕x2 ⊕x3 ⊕x4 = 0 where x1 , x2, x3 , x4 are Boolean variables, and ⊕ is the XOR operator.

Which one of the following must always be TRUE?

  1. x1 x2 x3 x4 = 0
  2. x1 x3 + x2 = 0
  3. x1x3 = x2x4
  4. x1 + x2 + x3 + x4 = 0

Answer: C

Explanation:

Assume, x1 = x2 = x3 = x4 = 1, Then applying XOR operator, we get
x1⊕x2⊕x3⊕x4 = 1⊕1⊕1⊕1 = 0
Now, take each option one by one and check
x1 x2 x3 x4 = 1.1.1.1 = 1-------------------- False
x1 x3 + x2 = 1.1+1 = 1------------ ----------False
x1x3 = x2x4 = 1 ---------------------True
x1 + x2 + x3 + x4 = 1+1+1+1 = 1 --------- False

Therefore option (C) is the right answer.


19) Let X be the number of distinct 16-bit integers in 2's complement representation. Let Y be the number of distinct 16-bit integers in sign magnitude representation. Then X -Y is ______________.

  1. 1
  2. 2
  3. 3
  4. 4

Answer: A

Explanation:

For range of n-bits, distinct values represented in 2's complement: -(2n-1) to +(2n-1 -1)
We can generalize it as: 2n
For range of n-bits, distinct values represented in Signed Magnitude: -(2n-1 -1) to 2n-1 -1
We can generalize it as: 2n - 1

Thus, X-Y = 2n - (2n - 1) = 1

Therefore option (A) is the right answer.


20) A processor has 40 distinct instructions and 24 general purpose registers. A 32-bit instruction word has an opcode, two register operands and an immediate operand. The number of bits available for the immediate operand field is ______________.

  1. 14
  2. 15
  3. 16
  4. 18

Answer: C

Explanation:

6 bits are needed for 40 distinct instructions (32(25) < 40 < 64(26))
5 bits are needed for 24 general purpose registers(16(24)< 24 < 32(25))
Total bits available =32
Thus. the number of bits available for the immediate operand field = 32 - (6 + 2*5) = 16
Therefore option (C) is the right answer.


21) Breadth First Search (BFS) is started on a binary tree beginning from the root vertex. There is a vertex t at a distance four from the root. If t is the n-th vertex in this BFS traversal, then the maximum possible value of n is ______________.

  1. 28
  2. 29
  3. 30
  4. 31

Answer: D

Explanation:

Given, height of tree = 4
Then the maximum possible value of n = 2h+1 - 1 = 25 - 1 = 32-1 = 31
Therefore option (D) is the right answer.


22) The value printed by the following program is ______________.

  1. 28
  2. 30
  3. 32
  4. 34

Answer: B

Explanation:

In ther given program, i = called by reference, and j = called by value. So, in function f() there might be change in the value of i only.

Now,
In function f(∗ p, m)
∗ p points to i
thus ∗ p = 5
And, m = 10 ( due to call by value of j)
Now, m = 10+5 <=> m = 15
∗ p = 5+15 <=> = 20
It returns nothing. Then goes to main function where i=20 and j = 10
Hence, output of printf("%d", i+j) = 20+10 = 30
Therefore option (B) is the right answer.


23) Assume that the algorithms considered here sort the input sequences in ascending order. If the input is already in ascending order, which of the following are TRUE?

I. Quicksort runs in Θ(n2 ) time
II. Bubblesort runs in Θ(n2 ) time
III. Mergesort runs in Θ(n) time
IV. Insertion sort runs in Θ(n) time

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

Answer: D

Explanation:

We know that if the input sequence is in ascending order, then
Quicksort algorithm runs in Θ(n2) time. This is true
Bubblesort algorithm runs in Θ(n2) time. This is false. It is because if there is no swap happens then, it can stop in a single loop.
Mergesort algorithm never runs more than Q(n log n). This is false
Insertion sort algorithm runs in Θ(n) time. This is true because it will finish in Θ(n) time in case of the sorted input sequence.
Therefore option (D) will be the right answer.


24) The Floyd-Warshall algorithm for all-pair shortest paths computation is based on

  1. Greedy paradigm.
  2. Divide-and-Conquer paradigm.
  3. Dynamic Programming paradigm.
  4. neither Greedy nor Divide-and-Conquer nor Dynamic Programming paradigm.

Answer: C

Explanation:

The Floyd Warshall's algorithm is based on the Dynamic Programming paradigm. In Floyd Warshall's algorithm, we find the shortest distance of all possibilities and select best one, so it is neither Divide & Conquer nor Greedy but based on Dynamic Programming Paradigm. Therefore option (C) is the right answer.


GATE 2016 CS Set 2-1
GATE 2016 CS Set 2-2
GATE 2016 CS Set 2-4
GATE 2016 CS Set 2-5
GATE 2016 CS Set 2-6
GATE 2016 CS Set 2-7
GATE 2016 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