Javatpoint Logo
Javatpoint Logo

GATE 2017 CS Set 1

1) The statement (¬ p) → (¬ q) is logically equivalent to which of the statements below?

I. p → q
II. q → p
III. (¬ q) ∨ p
IV. (¬ p) ∨ q

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

Answer: D



(¬ p) → (¬ q)


=> ¬ (¬ p) ∨ (¬ q) { we know, x → y = ¬ (x) ∨ y }
=> (¬ ¬ p) ∨ (¬ q)
=> (p) ∨ (¬ q) {because of double negation rule}
=> (¬ q) ∨ (p) (which is equivalent to statement (iii))
=> (q) → (p) { since x → y = ¬ (x) ∨ y } (which is equivalent to statement (ii))

Therefore, option (D) is the correct answer.

2) Consider the first-order logic sentence

F: ∀ x (∃ y R(x,y)).

Assuming non-empty logical domains, which of the sentences below are implied by F?

∃y (∃x R(x,y))
∃y (∀x R(x,y))
∀y (∃x R(x,y))
∼∃x (∀y R(x,y))

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

Answer: B



first order logic sentence --> F: ∀x (∃y R(x, y))

Now, keeping the statement one by one and check that they are implied by F or not:

(i) ∃y (∃x R(x, y))
            It is true. Because we have ∀x (∃y R(x, y)) → ∃x (∃y R(x, y)) → ∃y (∃x R(x, y)).

(ii) ∃y (∀x R(x, y))
            It is false. Because we have ∀x (∃y R(x, y)) ← ∃y (∀x R(x, y)).

(iii) ∀y (∃x R(x, y))
            It is false. Because for ∃y can not imply ∀y.

(iv) ∼∃x (∀y ∼R(x, y))
            It is true. Because ∼∃x (∀y ∼R(x, y)) = ∀x (∼ ∃y ∼ R(x, y)) = ∀x (∃y ∼∼(x, y)) = ∀x (∃y R(x, y)).

Therefore option (B) is the correct answer.

3) Let be scalars, not all zero. Such that the following expression holds: Gate 2017 CS set 1ci ai = 0

where ai is column vectors in Rn. Consider the set of linear equations.
Ax = b. where A = [] and b =Gate 2017 CS set 1ai Then, Set of equations has

  1. a unique solution has x = jn where j denotes n dimensional vector for all 1.
  2. no solution
  3. infinitely many solution
  4. finitely many solution

Answer: C


ici ai = 0 with ∃i : ci ≠ 0 indicates that column vectors of A [ a1, a2, ...., an] are linearly dependent. And Determinant of matrix A would be zero.

Therefore, For the system Ax = b,

Rank of coefficient matrix A = Rank of augmented matrix (A / B) = k (k< n)

So, the system Ax = b has infinitely many solutions.

Hence, the option (C) is the correct answer.

4) Consider the following functions from positives integers to real numbers 10, √n, n, log2n, 100/n. The CORRECT arrangement of the above functions in increasing order of asymptotic complexity is:

  1. log2n, 100/n, 10, √n, n
  2. 100/n, 10, log2n, √n, n
  3. 10, 100/n ,√n, log2n, n
  4. 100/n, log2n, 10 ,√n, n

Answer: B


10 is constant, so its growth rate is 0. Also, it is not affected by the value of n.

√n grows faster than log but slower than linear. (Consider √n2 / √n = √n, where as log(n2)logn = 2)

n: Its growth rate is linear.

log2n: Growth rate is logarithmic. Because in asymptotic growth, the base does not matter.

100 / n: Here growth rate decreases with n.

Hence, 100/n < 10 < log2n < √n < n

Therefore option (B) is the correct answer.

5) Consider the following table

Algorithms Design Paradigms
(P) Kruskal (i) Divide and Conquer
(Q) Quicksort (ii) Greedy
(R) Floyd-Warshall (iii) Dynamic Programming

Match the algorithm to design paradigms tey are based on:

  1. P-(ii), Q-(iii), R-(i)
  2. P-(iii), Q-(i), R-(ii)
  3. P-(ii), Q-(i), R-(iii)
  4. P-(i), Q-(ii), R-(iii)

Answer: C


Kruskal algorithm is used to find an edge of the most minimum weight (greediest) that connects any two trees in the forest. Hence, it is a greedy technique.

QuickSort is a Divide and Conquer algorithm. In every iteration, it picks an element as pivot and partitions the given array around the selected pivot value. In this, we partition the problem into subproblems, solve them and then combine. Hence, it is Divide & Conquer.

Floyd-Warshall uses Dynamic programming approach. It is used for solving the All-Pairs Shortest Path problem using Dynamic Programming.

Hence option (C) is the correct answer.

6) Let T be a binary search tree with 15 nodes. The minimum and maximum possible heights of T are:

  1. 4 and 15 respectively
  2. 3 and 14 respectively
  3. 4 and 14 respectively
  4. 3 and 15 respectively

Answer: B


Given node (n) = 15

We know that when the tree is fully skewed, then the height of the binary search tree will be maximum.

Gate 2017 CS set 1

So, Maximum height = n - 1
                        = 15 - 1
                       = 14

And when the tree is a fully complete tree, then the height of the binary search tree will be minimum.

Gate 2017 CS set 1

So, Minimum height = log2(n+1) - 1
                             = log2(15+1) - 1
                               = log2(16) - 1
                               = 4?1
                               = 3

Therefore option (B) is the correct answer.

7) The n-bit fixed-point representation of an unsigned real number X uses f bits for the fraction part. Let i = n - f. The range of decimal values for X in this representation is

  1. 2-f to 2i
  2. 2-f to ( 2i - 2-f)
  3. 0 to 2-i
  4. 0 to 2i - 2 -f)

Answer: D


                 Gate 2017 CS set 1

Minimum no. = 0

                 Gate 2017 CS set 1

                 Gate 2017 CS set 1

Max no. Possible with i bits = 2i - 1
                                            = 24 - 1
                                            = 16-1
                                            = 15

Max no. Possible with f bits = 1 - 2-f
                                           = 1- 2-4
                                           = 1- 1/2-4
                                           = 1-1/16
                                           = 15/16

Now, range = 2i - 1 + 1 - 2-f
                  = 2i - 2-f

Hence, maximum range = 0 to 2i - 2-f

Therefore option(D) is the correct answer.

8) Consider the C code fragment given below.

Assuming that m and n point to valid NULL-terminated linked lists, invocation of join will

  1. append list m to the end of list n for all inputs
  2. either cause a null pointer dereference or append list m to the end of list n
  3. cause a null pointer dereference for all inputs.
  4. append list n to the end of list m for all inputs.

Answer: B


According to question, m and n are valid Lists but it is not explicitly specified that the lists are empty or not. So we have two cases:

Case 1: If lists are not NULL
For Example:

Before join operation :
     m =1->2->3->4->5->null
     n =6->7->8->9->null

After join operation :

Case 2: If lists are NULL
   Then joining and referencing of m and n would create NULL pointer issue.
Hence, option(B) is the correct answer.

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

Please Share

facebook twitter google plus pinterest

B.Tech / MCA

Learn Latest Tutorials