Javatpoint Logo
Javatpoint Logo

GATE 2018 CS Set 3

1) Which one the following is a closed form expression for the generating function of the sequence {an}, where an = 2n + 3 for all n = 0, 1, 2,...?

  1. 3/(1-x)2
  2. 3x/(1-x)2
  3. 2-x/(1-x)2
  4. 3-x/(1-x)2

Answer: D


Given an = 2n + 3

Generating function G(x) for the sequence an is

Expanding above function we get,
= 2(0+x+2x2+3x3+.....) + 3(1+x+x2+......)
Now we take, (0+x+2x2+3x3+.....)
= x (1 + 2x + 3x2 + .....)
= x / (1-x)2
Also, 1+x+x2+..... = 1 / (1-x)

Now substituting these values in G(x) we get,
G(x) = 2(x/(1-x)2) + 3(1 / 1-x )
        = 2x+3-3x / (1-x)2)
        = 3-x / (1-x)2

Hence, the correct option is (D).

2) Consider the following C program.

The output of this program is:

  1. 0, c
  2. 0, a+2
  3. '0', 'a+2'
  4. '0', 'c'

Answer: A


char 'a' + 2 will become 'c'
So, Ournode p = {'1','0','c'}
*((char*)q+1) == p[1]
*((char*)q+2) == p[2]
printf("%c, %c", *((char*)q+1), *((char*)q+2));
Hence, Output = 0,c
Therefore the correct option is (A).

3) A queue is implemented using a non-circular singly linked list. The queue has a head pointer and a tail pointer, as shown in the figure. Let n denote the number of nodes in the queue. Let 'enqueue' be implemented by inserting a new node at the head, and 'dequeue' be implemented by deletion of a node from the tail.


Which one of the following is the time complexity of the most time-efficient implementation of 'enqueue' and 'dequeue, respectively, for this data structure?

  1. Θ(1), Θ(1)
  2. Θ(1), Θ(n)
  3. Θ(n), Θ(1)
  4. Θ(n), Θ(n)

Answer: B


Create new node N:

       N -> Data = Data
       N -> Next = Head
       Head = N

In this enqueue operation only pointer manipulation is involved which takes a constant amount of time.

Hence, Time Complexity = O(1)

Deletion of a node from Tail

For Dequeue operation, we make next pointer of second last node of single linked list NULL. In the singly linked list, we can not access its previous node, so we need to traverse the entire linked list to get second last node of linked list, i.e.,

       temp = head
       While(temp -> Next -> Next != NULL)
         temp = temp->next
       temp -> next = NULL
       tail = temp

Since, we are traversing the entire linked list for each Dequeue operation.

So, Time Complexity = O(n)

4) Let ⊕ and ⊙ denote the Exclusive OR and Exclusive NOR operations, respectively. Which one of the following is NOT CORRECT?


  1. A
  2. B
  3. C
  4. D

Answer: D



     (p⊕p)⊕q = 1⊕q = 1.q' + 0.q = q'


     (p⊙p')⊙(q') = 0⊙(q') = 0(q') + 1.(q')' = q

Hence, LHS ≠ RHS therefore, Option (D) is the correct answer.

5) Consider the following processor design characteristics.

I. Register-to-register arithmetic operations only
II. Fixed-length instruction format
III. Hardwired control unit

Which of the characteristics above are used in the design of a RISC processor?

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

Answer: D


In RISC the Instructions length cannot vary. It is usually fixed and of 32 bit. In CISC the Instructions length can be between 16 to 64 bits.

The hardwired control unit is used only when instructions are fixed.

Register to register operations is always possible in RISC. CISC can have both register to register operations and memory to memory instructions.

6) Let N be an NFA with n states. Let k be the number of states of a minimal DFA which is equivalent to N. Which one of the following is necessarily true?

  1. k ≥ 2n
  2. k ≥ n
  3. k ≤ n2
  4. k ≤ 2n

Answer: D


If NFA having n states then equivalent DFA can have atmost 2n states.

Hence, number of states in minimal DFA -> k ≤ 2n

7) The set of all recursively enumerable languages is

  1. closed under complementation.
  2. closed under intersection.
  3. a subset of the set of all recursive languages.
  4. an uncountable set.

Answer: B


We know that the Recursive Enumerable Language are closed under Union, Intersection, Concatenation but not Complementation.

So, we can easily say that option (A) is the correct answer.

8) Which one of the following statements is FALSE?

  1. Context-free grammar can be used to specify both lexical and syntax rules.
  2. Type checking is done before parsing.
  3. High-level language programs can be translated to different Intermediate Representations.
  4. Arguments to a function can be passed using the program stack.

Answer: B


Type checking performs at semantic analysis phase, and parsing performs at the syntax analysis phase. Since Syntax analysis phase comes before semantic analysis, therefore Type Checking is always done after parsing. Hence Option (B) is false and is the correct answer.

GATE 2018 CS Set 3-2
GATE 2018 CS Set 3-3
GATE 2018 CS Set 3-4
GATE 2018 CS Set 3-5
GATE 2018 CS Set 3-6
GATE 2018 CS Set 3-7
GATE 2018 CS Set 3-8
GATE Introduction

Please Share

facebook twitter google plus pinterest

B.Tech / MCA

Learn Latest Tutorials