• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests

GATE-CS-2003

Question 61

In a permutation a1.....an of n distinct integers, an inversion is a pair (ai, aj) such that i < j and ai > aj. What would be the worst-case time complexity of the Insertion Sort algorithm, if the inputs are restricted to permutations of 1.....n with at most n inversions?

  • Θ (n2)

  • Θ (n*log(n))

  • Θ (n1.5)

  • Θ (n)

Question 62

A data structure is required for storing a set of integers such that each of the following operations can be done in (log n) time, where n is the number of elements in the set.
   o	Delection of the smallest element 
   o	Insertion of an element if it is not already present in the set

Which of the following data structures can be used for this purpose?
  • A heap can be used but not a balanced binary search tree
  • A balanced binary search tree can be used but not a heap
  • Both balanced binary search tree and heap can be used
  • Neither balanced binary search tree nor heap can be used

Question 63

Let S be a stack of size n ≥ 1. Starting with the empty stack, suppose we push the first n natural numbers in sequence, and then perform n pop operations. Assume that Push and pop operation take X seconds each, and Y seconds elapse between the end of one such stack operation and the start of the next operation. For m ≥ 1, define the stack-life of m as the time elapsed from the end of Push(m) to the start of the pop operation that removes m from S. The average stack-life of an element of this stack is
  • n (X + Y)
  • 3Y + 2X
  • n (X + Y) - X
  • Y + 2X

Question 64

Consider the following 2-3-4 tree (i.e., B-tree with a minimum degree of two) in which each data item is a letter. The usual alphabetical ordering of letters is used in constructing the tree. GATECS2003Q65 What is the result of inserting G in the above tree ?
A) GATECS2003Q65A

B) GATECS2003Q65B

C) GATECS2003Q65C

D) None of the above

  • A
  • B
  • C
  • D

Question 65

Let G = (V, E) be an undirected graph with a subgraph G1 = (V1, El). Weights are assigned to edges of G as follows :

GATECS2003Q67 
A single-source shortest path algorithm is executed on the weighted graph (V, E, w) with an arbitrary vertex ν1 of V1 as the source. Which of the following can always be inferred from the path costs computed?
  • The number of edges in the shortest paths from ν1 to all vertices of G
  • G1 is connected
  • V1 forms a clique in G
  • G1 is a tree

Question 66

Consider the following dynamic programming code snippet for solving the 0/1 Knapsack problem:

Python
def knapsack(values, weights, capacity, n):
    if n == 0 or capacity == 0:
        return 0
    if weights[n-1] > capacity:
        return knapsack(values, weights, capacity, n-1)
    else:
        return max(values[n-1] + knapsack(values, weights, capacity-weights[n-1], n-1),
                   knapsack(values, weights, capacity, n-1))

Given the values [60, 100, 120] and weights [10, 20, 30], what would be the output of calling knapsack(values, weights, 50, 3)?

  • 180

  • 220

  • 280

  • 300

Question 67

The following are the starting and ending times of activities A, B, C, D, E, F, G and H respectively in chronological order: "asbscsaedsceesfsbedegseefehsgehe" Here, xs denotes the starting time and xe denotes the ending time of activity X. W need to schedule the activities in a set of rooms available to us. An activity can be scheduled in a room only if the room is reserved for the activity for its entire duration. What is the minimum number of rooms required ?
  • 3
  • 4
  • 5
  • 6

Question 68

Let G (V, E) be a directed graph with n vertices. A path from vi to vj in G is sequence of vertices (vi, vi+1, ......., vj) such that (vk, vk+1) ∈ E for all k in i through j - 1. A simple path is a path in which no vertex appears more than once. Let A be an n x n array initialized as follow
GATECS2003Q70 
Consider the following algorithm.
for i = 1 to n
   for j = 1 to n
      for k = 1 to n
         A [j , k] = max (A[j, k] (A[j, i] + A [i, k]); 
Which of the following statements is necessarily true for all j and k after terminal of the above algorithm ?
  • A[j, k] ≤ n
  • If A[j, k] ≥ n - 1, then G has a Hamiltonian cycle
  • If there exists a path from j to k, A[j, k] contains the longest path lens from j to k
  • If there exists a path from j to k, every simple path from j to k contain most A[j, k] edges

Question 69

Consider the following logic program P A(x) <- B(x, y), C(y) <- B(x,x) Which of the following first order sentences is equivalent to P?
GATECS2003Q71
  • A
  • B
  • C
  • D

Question 70

The following resolution rule is used in logic programming.

Derive clause (P ∨ Q) from clauses (P ∨ R), (Q ∨ ¬R) 

Which of the following statements related to this rule is FALSE?

  • ((P ∨ R) ∧ (Q ∨ ¬R)) ⇒ (P ∨ Q) is logically valid

  • (P ∨ Q) ⇒ ((P ∨ R)) ∧ (Q ∨ ¬R)) is logically valid

  • (P ∨ Q) is satisfiable if and only if (P ∨ R) ∨ (Q ∨ ¬R) is satisfiable

  • (P ∨ Q) ⇒ FALSE if and only if both P and Q are unsatisfiable

There are 89 questions to complete.

Last Updated :
Take a part in the ongoing discussion