• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests

GATE CS 2008

Question 41

The subset-sum problem is defined as follows. Given a set of n positive integers, S = {a1 ,a2 ,a3 ,...,an} and positive integer W, is there a subset of S whose elements sum to W? A dynamic program for solving this problem uses a 2-dimensional Boolean array X, with n rows and W+1 columns. X[i, j], 1 <= i <= n, 0 <= j <= W, is TRUE if and only if there is a subset of {a1 ,a2 ,...,ai} whose elements sum to j. Which of the following is valid for 2 <= i <= n and ai <= j <= W?
  • X[i, j] = X[i - 1, j] V X[i, j -ai]
  • X[i, j] = X[i - 1, j] V X[i - 1, j - ai]
  • X[i, j] = X[i - 1, j] V X[i, j - ai]
  • X[i, j] = X[i - 1, j] V X[i -1, j - ai]

Question 42

Dijkstra’s single source shortest path algorithm when run from vertex a in the below graph, computes the correct shortest path distance to
  • only vertex a
  • only vertices a, e, f, g, h
  • only vertices a, b, c, d
  • all the vertices

Question 43

You are given the postorder traversal, P, of a binary search tree on the n elements 1, 2, ..., n. You have to determine the unique binary search tree that has P as its postorder traversal. What is the time complexity of the most efficient algorithm for doing this?

  • O(Logn)

  • O(n)

  • O(nLogn)

  • none of the above, as the tree cannot be uniquely determined.

Question 44

We have a binary heap on n elements and wish to insert n more elements (not necessarily one after another) into this heap. The total time required for this is
(A) [Tex]\\theta [/Tex](logn)
(B) [Tex]\\theta[/Tex](n)
(C) [Tex]\\theta[/Tex](nlogn)
(D) [Tex]\\theta[/Tex](n^2)
  • A
  • B
  • C
  • D

Question 45

Which of the following statements is false?
  • Every NFA can be converted to an equivalent DFA
  • Every non-deterministic Turing machine can be converted to an equivalent deterministic Turing machine
  • Every regular language is also a context-free language
  • Every subset of a recursively enumerable set is recursive

Question 46

Given below are two finite state automata (→ indicates the start state and F indicates a final state)Which of the following represents the product automaton Z×Y? 

[caption width="800"] [/caption]
  • A

  • B

  • C

  • D

Question 47

Which of the following statements are true?
I. Every left-recursive grammar can be converted to a 
   right-recursive grammar and vice-versa
II. All [Tex]\\epsilon[/Tex] productions can be removed from any context-free 
    grammar by suitable transformations
III. The language generated by a context-free grammar all of whose 
     productions are of the form X --> w or X --> wY (where, w is a string of 
     terminals and Y is a non-terminal), is always regular
IV. The derivation trees of strings generated by a context-free grammar 
    in Chomsky Normal Form are always binary trees 
  • I, II, III and IV
  • II, III and IV only
  • I, III and IV only
  • I, II and IV only

Question 48

Match the following:
GATECS200851
  • E - P, F - R, G - Q, H - S
  • E - R, F - P, G - S, H - Q
  • E - R, F - P, G - Q, H - S
  • E - P, F - R, G - S, H - Q

Question 49

Match the following NFAs with the regular expressions they correspond to

 1. ϵ + 0(01*1 + 00) * 01*
 2. ϵ + 0(10 *1 + 00) * 0
 3. ϵ + 0(10 *1 + 10) *1
 4. ϵ + 0(10 *1 + 10) *10 *
[caption width="800"] [/caption]
  • P - 2, Q - 1, R - 3, S - 4

  • P - 1, Q - 3, R - 2, S - 4

  • P - 1, Q - 2, R - 3, S - 4

  • P - 3, Q - 2, R - 1, S - 4

Question 50

Which of the following are regular sets?

  • {anb2m|n≥0, m≥0}

  • {anbm | n = 2m}

  •  {anbm n≠m}

  •  {xcy | x,y ∈ {a,b}*}

There are 85 questions to complete.

Last Updated :
Take a part in the ongoing discussion