Consider the following class definitions in a hypothetical Object Oriented language that supports inheritance and uses dynamic binding. The language should not be assumed to… Read More
Tag Archives: GATE-GATE-CS-2003
The following program fragment is written in a programming language that allows variables and does not allow nested declarations of functions. global int i =… Read More
The following program fragment is written in a programming language that allows variables and does not allow nested declarations of functions. global int i =… Read More
The following resolution rule is used in logic programming. Derive clause (P ∨ Q) from clauses (P ∨ R), (Q ∨ ¬R) Which of the… Read More
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? (A)… Read More
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,… Read More
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… Read More
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… Read More
Let G = (V, E) be an undirected graph with a subgraph G1 = (V1, El). Weights are assigned to edges of G as follows… Read More
The cube root of a natural number n is defined as the largest natural number m such that m3 ≤ n. The complexity of computing… Read More
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… Read More
Let S be a stack of size n ≥ 1. Starting with the empty stack, suppose we push the first n natural numbers in sequence,… Read More
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,… Read More
In a permutation a1…..an of n distinct integers, an inversion is a pair (ai, aj) such that i < j and ai > aj. What… Read More
In a permutation a1…..an of n distinct integers, an inversion is a pair (ai, aj) such that i aj. If all permutations are equally likely,… Read More