GATE Computer Science Sample Paper 2007
GATE Computer Science Sample Paper 2007
M
CO
2. Let S be a set of n elements. The number of ordered pairs in the largest and the
smallest equivalence relations on S are:
(A) n and n (B) n2 and n (C) n2 and 0 (D) n and 1
E.
3. What is the maximum number of different Boolean functions involving n Boolean
AT
variables?
n 2
(A) n2 (B) 2n (C) 22 (D) 2n
PG
4. Let G be the non-planar graph with the minimum possible number of edges. Then
G has
(A) 9 edges and 5 vertices (B) 9 edges and 6 vertices
TO
5.
2 5
ON
W.
1 4
6
3
WW
www.onestopgate.com
Page 2
CSComputer Science: Gate 2007 Paper
8. How many 3-to-8 line decoders with an enable input are needed to construct a 6-
to-64 line decoder without using any other logic gates?
(A) 7 (B) 8 (C) 9 (D) 10
M
CO
9. Consider the following Boolean function of four variables:
f (w , x ,y , z ) = ∑ (1,3, 4, 6, 9,11,12,14)
The function is:
E.
(A) independent of one variables. (B) independent of two variables.
(C) independent of three variables. (D) dependent on all the variables.
AT
10. Consider a 4-way set associative cache consisting of 128 lines with a line size of
64 words. The CPU generates a 20-bit address of a word in main memory. The
PG
number of bits in the TAG, LINE and WORD fields are respectively:
(A) 9, 6, 5 (B) 7, 7, 6 (C) 7, 5, 8 (D) 9, 5, 6
TO
11. Consider a disk pack with 16 surfaces, 128 tracks per surface and 256 sectors
per track. 512 bytes of data are stored in a bit serial manner in a sector. The
capacity of the disk pack and the number of bits required to specify a particular
ES
12. The height of a binary tree is the maximum number of edges in any root to leaf
path. The maximum number of nodes in a binary tree of height h is:
W.
13. The maximum number of binary trees that can be formed with three unlabeled
nodes is:
(A) 1 (B) 5 (C) 4 (D) 3
14. Which of the following sorting algorithms has the lowest worst-case complexity?
(A) Merge sort (B) Bubble sort (C) Quick sort (D) Selection sort
www.onestopgate.com
Page 3
CSComputer Science: Gate 2007 Paper
M
16. Group 1 contains some CPU scheduling algorithms and Group 2 contains some
applications. Match entries in Group 1 to entries in Group 2.
CO
Group I Group II
(P) Gang Scheduling (1) Guaranteed Scheduling
E.
(Q) Rate Monotonic Scheduling (2) Real-time Scheduling
(R) Fair Share Scheduling (3) Thread Scheduling
AT
(A) P - 3 Q - 2 R - 1 (B) P - 1 Q - 2 R - 3
(C) P - 2 Q - 3 R - 1 (D) P - 1 Q - 3 R - 2
PG
17. Consider the following statements about user level threads and kernel level
threads. Which one of the following statements is FALSE?
TO
(A) Context switch time is longer for kernel level threads than for user level
threads.
ES
(D) Blocking one kernel level thread blocks all related threads.
19. In Ethernet when Manchester encoding is used, the bit rate is:
(A) Half the baud rate. (B) Twice the baud rate.
(C) Same as the baud rate. (D) None of the above
20. Which one of the following uses UDP as the transport protocol?
(A) HTTP (B) Telnet (C) DNS (D) SMTP
www.onestopgate.com
Page 4
21. How many different non-isomorphic Abelian groups of order 4 are there?
(A) 2 (B) 3 (C) 4 (D) 5
22. Let Graph(x) be a predicate which denotes that x is a graph. Let Connected(x) be
a predicate which denotes that x is connected. Which of the following first order
logic sentences DOES NOT represent the statement: “Not every graph is
connected”?
(A) ¬∀ x ( Graph ( x ) ⇒ Connected ( x ) ) (B) ∃x ( Graph ( x ) ∧ ¬Connected ( x ) )
M
(C) ¬∀x ( ¬Graph ( x ) ∨ Connected ( x ) ) (D) ∀x ( Graph ( x ) ⇒ ¬Connected ( x ) )
CO
23. Which of the following graphs has an Eulerian circuit?
E.
(A) Any k-regular graph where k is an even number.
(B) A complete graph on 90 vertices.
AT
(C) The complement of a cycle on 25 vertices.
(D) None of the above
PG
24. Suppose we uniformly and randomly select a permutation from the 20!
Permutations of 1, 2,3 ,…..,20. What is the probability that 2 appears at an
earlier position than any other even number in the selected permutation?
TO
1 1 9!
(A) (B) (C) (D) None of these
2 10 20!
ES
25. Let A be a 4 × 4 matrix with eigenvalues -5, -2, 1, 4. Which of the following is an
A I
eigenvalue of , where I is the 4 × 4 identity matrix?
ON
I A
(A) -5 (B) -7 (C) 2 (D) 1
W.
{ } { } { } { }
S : π 1 = abcd , π 2 = ab, cd , π 3 = abc, d , π 4 = a, b, c, d . Let p be the partial
WW
(A) π1 (B)
π1
π2
π2 π4
π3
π4 π3
www.onestopgate.com
Page 5
(C) π1 (D)
π2
π1 π3
π2 π3
π4
π4
M
27. Consider the set of (column) vectors defined by
{ }.
CO
T
X = x ∈ R3 x1 + x2 + x3 = 0, where x T = x1 , x2 , x3 Which of the following is
TRUE?
E.
T T
(A) , 1, 0, −1
AT
therefore is not a basis of X.
(C) X is not a subspace of R3
PG
(D) None of the above
TO
xn 9
28. Consider the series xn +1 = + , x0 = 0.5 obtained from the Newton-Raphson
2 8 xn
method. The series converges to
ES
{
L = w w ∈ {0,1} , number of 0s and 1s in w are divisible by 3 and 5, respectively
*
}
has
W.
{ }
The language L = 0i 21i i ≥ 0 over the alphabet {0,1, 2} is:
WW
30.
www.onestopgate.com
Page 6
{
(A) ww R w ∈ {0,1 }
+
} (B) {ww x x, w ∈ {0,1} }
R +
32. Let f (w, x, y , z ) = ∑ (0, 4,5, 7, 8, 9,13,15) . Which of the following expressions are
NOT equivalent to f ?
(P) x ′y ′z ′ + w ′xy ′ + wy ′z + xz
M
(Q) w ′y ′z ′ + wx ′y ′ + xz
CO
(R) w ′y ′z ′ + wx ′y ′ + xyz + xy ′z
(S) x ′y ′z ′ + wx ′y ′ + w ′y
E.
(A) P only (B) Q and S (C) R and S (D) S only
33. Define the connective * for the Boolean variables X and Y as: X * Y = XY + X ′Y ′.
AT
Let Z = X * Y . Consider the following expressions P, Q and R.
πP : X = Y * Z Q :Y = X * Z R : X *Y * Z = 1
PG
Which of the following is TRUE?
(A) Only P and Q are valid. (B) Only Q and R are valid.
(C) Only P and R are valid. (D) All P, Q, R are valid.
TO
34. Suppose only one multiplexer and one inverter are allowed to be used to
implement any Boolean function of n variables. What is the minimum size of the
ES
multiplexer needed?
(A) 2n line to 1 line (B) 2n +1 line to 1 line
(C) 2n −1 line to 1 line (D) 2n − 2 line to 1 line
ON
35. In a look-ahead carry generator, the carry generate function Gi and the carry
W.
The expressions for the sum bit Si and the carry bit Ci +1 of the look-ahead carry
adder are given by:
Si = Pi ⊕ Ci and Ci +1 = Gi + Pi Ci , where C0 is the input carry.
Consider a two-level logic implementation of the look-ahead carry generator.
Assume that all Pi and Gi are available for the carry generator circuit and that
the AND and OR gates can have any number of inputs. The number of AND gates
and OR gates needed to implement the look-ahead carry generator for a 4-bit
adder with S3 , S2 , S1 , S0 and C4 as its outputs are respectively:
(A) 6, 3 (B) 10, 4 (C) 6, 4 (D) 10, 5
www.onestopgate.com
Page 7
36. The control signal functions of a 4-bit binary counter are given below (where X is
“don’t care”):
0 ↑ 0 1 Count next
M
CO
The counter is connected as follows:
A4 A3 A2 A1
E.
AT
Count=1
Clear 4-bit counter Load=0
Clock
PG
Inputs
TO
0 0 1 1
Assume that the counter and gate delays are negligible. If the counter starts at
0, then it cycles through the following sequence:
ES
(A) 0, 3, 4 (B) 0, 3, 4, 5
(C) 0, 1, 2, 3, 4 (D) 0, 1, 2, 3, 4, 5
ON
www.onestopgate.com
Page 8
CSComputer Science: Gate 2007 Paper
38. The following postfix expression with single digit operands is evaluated using a
stack:
8 2 3∧ / 2 3 * + 5 1 * -
Note that ∧ is the exponentiation operator. The top two elements of the stack
after the first * is evaluated are:
(A) 6, 1 (B) 5, 7 (C) 3, 2 (D) 1, 5
M
39. The inorder and preorder traversal of a binary tree are
CO
d b e a f c g and a b d e c f g, respectively
The postorder traversal of the binary tree is:
(A) d e b f g c a (B) e d b g f c a (C) e d b f g c a (D) d e f g b c a
E.
40. Consider a hash table of size seven, with starting index zero, and a hash function
(3x + 4 ) mod7. Assuming the hash table is initially empty, which of the following
AT
is the contents of the table when the sequence 1, 3, 8, 10 is inserted into the
table using closed hashing? Note that − denotes an empty location in the table.
PG
(A) 8, −, −, −, −, −, 10 (B) 1, 8, 10, −, −, −, 3
(C) 1, −, −, −, −, −, 3 (D) 1, 10, 8, −, −, −, 3
TO
41. In an unweighted, undirected connected graph, the shortest path from a node S
to every other node is computed most efficiently, in terms of time complexity, by
(A) Dijkstra’s algorithm starting from S.
ES
int f(int n)
{static int r = 0;
if (n <= 0) return 1;
WW
if (n > 3)
{r = n;
return f(n-2)+2;
}
return f(n-1)+r;
}
What is the value of f (5 ) ?
www.onestopgate.com
Page 9
CSComputer Science: Gate 2007 Paper
43. A complete n-ary tree is a tree in which each node has n children or no children.
Let I be the number of internal nodes and L be the number of leaves in a
complete n-ary tree. If L = 41, and I = 10, what is the value of n?
(A) 3 (B) 4 (C) 5 (D) 6
M
n = n%m;
return gcd(m,n);
CO
}
How many recursive calls are made by this function?
E.
(A) Θ (log2 n ) (B) Ω ( n ) (C) Θ (log2 log2 n ) (D) Θ ( n)
AT
45. What is the time complexity of the following recursive function:
int DoSomething (int n) {
if (n <= 2)
PG
return 1;
else
TO
46. Consider the following C program segment where CellNode represents a node in a
ON
binary tree:
struct CellNode {
struct CellNOde *leftChild;
W.
int element;
struct CellNode *rightChild;
WW
};
int GetValue (struct CellNode *ptr) {
int value = 0;
if (ptr != NULL) {
if ((ptr->leftChild == NULL) &&
(ptr->rightChild == NULL))
value = 1;
else
value = value + GetValue(ptr->leftChild)
www.onestopgate.com
Page 10
+ GetValue(ptr->rightChild);
}
return(value);
}
The value returned by GetValue when a pointer to the root of a binary tree is
passed as its argument is:
(A) the number of nodes in the tree
(B) the number of internal nodes in the tree
(C) the number of leaf nodes in the tree
M
(D) the height of the tree
CO
47. Consider the process of inserting an element into a Max Heap, where the Max
Heap is represented by an array. Suppose we perform a binary search on the
E.
path from the new leaf to the root to find the position for the newly inserted
element, the number of comparisons performed is:
(A) Θ (log2 n ) (B) Θ (log2 log2 n ) (C) Θ ( n ) (D) Θ ( n log2 n )
AT
48. Which of the following is TRUE about formulae in Conjunctive Normal Form?
(A) For any formula, there is a truth assignment for which at least half the
PG
clauses evaluate to true.
(B) For any formula, there is a truth assignment for which all the clauses
evaluate to true.
TO
(C) There is a formula such that for each truth assignment, at most one-fourth of
the clauses evaluate to true.
(D) None of the above.
ES
49. Let w be the minimum weight among all edge weights in an undirected connected
ON
www.onestopgate.com
Page 11
CSComputer Science: Gate 2007 Paper
M
Let T ( n ) denote the number of times the for loop is executed by the program on
CO
input n. Which of the following is TRUE?
E.
(C) T ( n ) = O ( n ) and T ( n ) = Ω ( n ) (D) None of the above
AT
52. Consider the grammar with non-terminals N = {S, C , S1} , terminals
T = {a, b, i, t , e} , with S as the start symbol, and the following set of rules:
PG
S → iCtSS1 a
S1 → eS ε
C →b
TO
www.onestopgate.com
Page 12
CSComputer Science: Gate 2007 Paper
t1 = a + b
t2 = c + d
t3 = e − t2
t4 = t1 − t3
Assume that all operands are initially in memory. The final value of the
computation should be in memory. What is the minimum number of MOV
instructions in the code generated for this basic block?
(A) 2 (B) 3 (C) 5 (D) 6
M
55. An operating system uses Shortest Remaining Time first (SRT) process
scheduling algorithm. Consider the arrival times and execution times for the
CO
following processes:
E.
Process Execution time Arrival time
P1 20 0
P2 25 15
AT
P3 10 30
P4 15 45
PG
What is the total waiting time for process P2?
(A) 5 (B) 15 (C) 40 (D) 55
TO
56. A virtual memory system uses First In First Out (FIFO) page replacement policy
and allocates a fixed number of frames to a process. Consider the following
ES
statements:
P: Increasing the number of page frames allocated to a process sometimes
increases the page fault rate.
ON
57. A single processor system has three resource types X, Y and Z, which are shared
by three processes. There are 5 units of each resource type. Consider the
following scenario, where the column alloc denotes the number of units of each
resource type allocated to each process, and the column request denotes the
number of units of each resource type requested by a process in order to
complete execution. Which of these processes will finish LAST?
www.onestopgate.com
Page 13
CSComputer Science: Gate 2007 Paper
alloc request
X Y Z X Y Z
P0 1 2 1 1 0 3
P1 2 0 1 0 1 2
P2 2 2 1 1 2 0
M
58. Two processes, P1 and P2, need to access a critical section of code. Consider the
CO
following synchronization construct used by the processes:
/* P1 */ /* P2 */
E.
while (true) { while (true) {
wants1 = true; wants2 = true;
while (wants2==true); while (wants1==true);
AT
/* Critical /* Critical
Section */ Section */
wants1=false; Wants2=false;
} }
PG
/* Remainder section */ /* Remainder section */
TO
Here, wants1 and wants2 are shared variables, which are initialized to false.
Which one of the following statements is TRUE about the above construct?
ES
www.onestopgate.com
Page 14
CSComputer Science: Gate 2007 Paper
60. Consider the relation employee(name, sex, supervisorName) with name as the
key. supervisorName gives the name of the supervisor of the employee under
consideration. What does the following Tuple Relational Calculus query produce?
{e.name employee (e ) ∧ }
( ∀x ) ¬employee ( x ) ∨ x.supervisorName ≠ e.name ∨ x.sex = "male" }
(A) Names of employees with a male supervisor.
(B) Names of employees with no immediate male subordinates.
(C) Names of employees with no immediate female subordinates.
M
(D) Names of employees with a female supervisor.
CO
61. Consider the table employee(empId, name, department, salary) and the two
queries Q1 , Q2 below. Assuming that department 5 has more than one employee,
E.
and we want to find the employees who get higher salary than anyone in the
department 5, which one of the statements is TRUE for any arbitrary employee
table?
Q1 : Select e.empId
AT
From employee e
Where not exists
PG
(Select * From employee s where s.department = “5” and s.salary >=e.salary)
Q2 : Select e.empId
TO
From employee e
Where e.salary > Any
(Select distinct salary From employee s Where s.department = “5”)
ES
(B) A relation in which every key has only one attribute is in 2NF
(C) A prime attribute can be transitively dependent on a key in a 3 NF relation.
(D) A prime attribute can be transitively dependent on a key in a BCNF relation.
63. The order of a leaf node in a B + − tree is the maximum number of (value, data
record pointer) pairs it can hold. Given that the block size is 1K bytes, data
record pointer is 7 bytes long, the value field is 9 bytes long and a block pointer
is 6 bytes long, what is the order of the leaf node?
(A) 63 (B) 64 (C) 67 (D) 68
www.onestopgate.com
Page 15
CSComputer Science: Gate 2007 Paper
64. Consider the following schedules involving two transactions. Which one of the
following statements is TRUE?
S1 : r1 (X ); r1 (Y ); r2 (X ); r2 (Y );w2 (Y );w1 (X )
S2 : r1 ( X ) ; r2 ( X ) ; r2 (Y ) ;w2 (Y ) ; r1 (Y ) ;w1 ( X )
M
CO
65. There are n stations in a slotted LAN. Each station attempts to transmit with a
probability p in each time slot. What is the probability that ONLY one station
transmits in a given time slot?
E.
n −1
(A) np (1 − p ) (B) (1 − p )n −1 (C) p (1 − p )
n −1
(D) 1 − (1 − p )
n −1
AT
66. In a token ring network the transmission speed is 107 bps and the propagation
speed is 200 metres/µs. The 1-bit delay in this network is equivalent to:
(A) 500 metres of cable. (B) 200 metres of cable.
PG
(C) 20 metres of cable. (D) 50 metres of cable.
67. The address of a class B host is to be split into subnets with a 6-bit subnet
TO
number. What is the maximum number of subnets and the maximum number of
hosts in each subnet?
(A) 62 subnets and 262142 hosts. (B) 64 subnets and 262142 hosts.
ES
(C) 62 subnets and 1022 hosts. (D) 64 subnets and 1024 hosts.
ON
69. The distance between two stations M and N is L kilometers. All frames are K bits
WW
long. The propagation delay per kilometer is t seconds. Let R bits/second be the
channel capacity. Assuming that processing delay is negligible, the minimum
number of bits for the sequence number field in a frame for maximum utilization,
when the sliding window protocol is used, is:
2LtR + 2K 2LtR
(A) log2 (B) log2
K K
2LtR + K 2LtR + K
(C) log2 (D) log2
K 2K
www.onestopgate.com
Page 16
CSComputer Science: Gate 2007 Paper
M
(A) P - 2 Q - 1 R - 3 S - 5
CO
(B) P - 1 Q - 4 R - 2 S - 3
(C) P - 1 Q - 4 R - 2 S - 5
(D) P - 2 Q - 4 R - 1 S - 3
E.
Common Data Questions
AT
Common Data for Questions 71, 72, 73:
Consider the following program segment. Here R1, R2 and R3 are the general purpose
PG
registers.
ADD R2, R1 R2 R1 + R2 1
MOV (R3), R2 M[R3] R2 1
INC R3 R3 R3 + 1 1
ON
DEC R1 R1 R1 – 1 1
BNZ LOOP Branch on not zero 2
W.
HALT Stop 1
WW
Assume that the content of memory location 3000 is 10 and the content of the register
R3 is 2000. The content of each of the memory locations from 2000 to 2010 is 100. The
program is loaded from the memory location 1000. All the numbers are in decimal.
71. Assume that the memory is word addressable. The number of memory references
for accessing the data in executing the program completely is:
(A) 10 (B) 11 (C) 20 (D) 21
72. Assume that the memory is word addressable. After the execution of this
program, the content of memory location 2010 is:
(A) 100 (B) 101 (C) 102 (D) 110
www.onestopgate.com
Page 17
73. Assume that the memory is byte addressable and the word size is 32 bits. If an
interrupt occurs during the execution of the instruction “INC R3”, what return
address will be pushed on to the stack?
(A) 1005 (B) 1020 (C) 1024 (D) 1040
q3
M
a
CO
b b b
a b
q0 q1 q2
E.
a
a
AT
74. The language accepted by this automaton is given by the regular expression
1 1 1 1 1 1
Suppose the letters a, b, c, d, e, f have probabilities , , , , , , respectively.
2 4 8 16 32 32
76. Which of the following is the Huffman code for the letter a, b, c, d, e, f?
W.
www.onestopgate.com
Page 18
CSComputer Science: Gate 2007 Paper
S → aB S → bA
B→b A→a
B → bS A → aS
B → aBB S → bAA
79. For the correct answer strings to Q.78, how many derivation trees are there?
M
(A) 1 (B) 2 (C) 3 (D) 4
CO
Statement for Linked Answer Questions 80 & 81:
Consider a machine with a byte addressable main memory of 216 bytes. Assume that a
E.
direct mapped data cache consisting of 32 lines of 64 bytes each is used in the system.
A 50 × 50 two-dimensional array of bytes is stored in the main memory starting from
memory location 1100H. Assume that the data cache is initially empty. The complete
AT
array is accessed twice. Assume that the contents of the data cache do not change in
between the two accesses.
PG
80. How many data cache misses will occur in total?
(A) 48 (B) 50 (C) 56 (D) 59
TO
81. Which of the following lines of the data cache will be replaced by new blocks in
accessing the array for the second time?
(A) line 4 to line 11 (B) line 4 to line 12
ES
83. Least Recently Used (LRU) page replacement policy is a practical approximation
to optimal page replacement. For the above reference string, how many more
page faults occur with LRU than with the optimal page replacement policy?
(A) 0 (B) 1 (C) 2 (D) 3
www.onestopgate.com
Page 19
M
CO
85. Suppose that the robot is not allowed to traverse the line segment from (4,4) to
(5,4). With this constraint, how many distinct paths are there for the robot to
reach (10,10) starting from (0,0)?
E.
(A) 29 (B) 219
8 11 20 8 11
(C) × (D) − ×
AT
4 5 10 4 5
PG
TO
ES
ON
W.
WW
www.onestopgate.com