Anda di halaman 1dari 116

GATE CS - 1999 GATE Forum www.gateIorum.

com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con
Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum
SECTION - A
1. This question consists of TWENTY-FIVE multiple questions of ONE mark each. For
each question, four possible alternatives (A, B, C and D) are given, out of which
ONLY ONE is correct. Indicate the correct answer in the boxes corresponding to
the questions only on the FIRST sheet of the answer book.

1.1 Suppose that the expectation of a random variable X is 5. Which of the following
statements is true?
(a) There is a sample point at which X has the value 5.
(b) There is a sample point at which X has value greater than 5.
(c) There is a sample point at which X has a value greater than or equal to 5.
(d) None of the above

1.2 The number of binary relations on a set with n elements is:

(a)
2
n (b) 2
n

(c)
2
2
n
(d) None of the above

1.3 The number of binary strings of n zeroes and k ones that no two ones are
adjacent is
(a)
1 n
k
C

(b)
n
k
C
(c)
1
n
k
C
+
(d) None of the above

1.4 Consider the regular expression (0 + 1) (0 + 1).. N times. The minimum state
finite automation that recognizes the language represented by this regular
expression contains
(a) n states (b) n + 1 states
(c) n + 2 states (d) None of the above

1.5 Context-free languages are closed under:
(a) Union, intersection (b) Union, Kleene closure
(c) Intersection, complement (d) Complement, Kleene closure

1.6 Let L
D
be the set of all languages accepted by a PDA by final state and L
E
the set
of all languages accepted by empty stack. Which of the following is true?
(a) L
D
= L
E
(b) L
D


L
E
(c) L
E
= L
D
(d) None of the above

1.7 Which of the following expressions is not equivalent to x ?
(a) x NAND X (b) x NOR x (c) x NAND 1 (d) x NOR 1
GATE CS - 1999 GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con
Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum

1.8 Which of the following functions implements the Karnaugh map shown below?

CD
AB
00 00 11 10
00 0 0 1 0
01 X X 1 X
11 0 1 1 0
10 0 1 1 0

(a) AB CD + (b) D(C +A)
(c) AD + AB (d) ( ) ( ) ( ) C D C D A B + + + +

1.9 Listed below are some operating system abstractions (in the left column) and the
hardware components (in the right column)?






(a) (A) - 2 (B) - 4 (C) - 3 (D) - 1 (b) (A) - 1 (B) - 2 (C) - 3 (D) - 4
(c) (A) - 3 (B) - 2 (C) - 4 (D) - 1 (d) (A) - 4 (B) - 1 (C) - 2 (D) - 3

1.10 Which of the following disk scheduling strategies is likely to give the best through
put?
(a) Farthest cylinder next (b) Nearest cylinder next
(c) First come first served (d) Elevator algorithm

1.11 System calls are usually invoked by using
(a) a software interrupt (b) polling
(c) an indirect jump (d) a privileged instruction

1.12 A sorting technique is called stable if
(a) it takes O (nlog n) time
(b) it maintains the relative order of occurrence of non-distinct elements
(c) it uses divide and conquer paradigm
(d) it takes O(n) space
(A) Thread 1. Interrupt
(B) Virtual address space 2. Memory
(C) File system 3. CPU
(D) Signal 4. Disk
GATE CS - 1999 GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con
Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum

1.13 Suppose we want to arrange the n numbers stored in any array such that all
negative values occur before all positive ones. Minimum number of exchanges
required in the worst case is
(a) n - 1 (b) n
(c) n + 1 (d) None of the above

1.14 If one uses straight two-way merge sort algorithm to sort the following elements
in ascending order:
20, 47, 15, 8, 9, 4, 40, 30, 12, 17
then the order of these elements after second pass of the algorithm is:
(a) 8, 9, 15, 20, 47, 4, 12, 17, 30, 40
(b) 8, 15, 20, 47, 4, 9, 30, 40, 12, 17
(c) 15, 20, 47, 4, 8, 9, 12, 30, 40, 17
(d) 4, 8, 9, 15, 20, 47, 12, 17, 30, 40

1.15 The number of articulation points of the following graph is








(a) 0 (b) 1 (c) 2 (d) 3

1.16 If n is a power of 2, then the minimum number of multiplications needed to
compute a* is
(a) log
2
n (b) n (c) n -1 (d) n

1.17 Which of the following is the most powerful parsing method?
(a) LL (1) (b) Canonical LR (c) SLR (d) LALR

1.18 Consider the join of a relation R with a relation S. If R has m tuples and S has n
tuples then the maximum and minimum sizes of the join respectively are
(a) m + n and 0 (b) mn and 0
(c) m + n and |m - n| (d) mn and m + n

1
2 3
4
5
6
7
GATE CS - 1999 GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con
Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum
1.19. The relational algebra expression equivalent to the following tuple calculus
expression:

( )
{ }
10 20 t t r t A t B = =

is
(a)
( )
( )
10 20 A B
r
= =
(b)
( )
( )
( )
( )
10 20 A B
r r
= =

(c)
( )
( )
( )
( )
10 20 A B
r r
= =
(d)
( )
( )
( )
( )
10 20 A B
r r
= =


1.20. Booths coding in 8 bits for the decimal number -57 is
(a) 0 - 100 + 1000 (b) 0 - 100 + 100 -1
(c) 0 - 1 + 100 - 10 + 1 (d) 0 0 - 10 + 100 - 1

1.21. The maximum gate delay for any output to appear in an array multiplier for
multiplying two n bit number is
(a) O
( )
2
n (b) O(n) (c) O(log n) (d) O(1)

1.22. The main memory of a computer has 2 cm blocks while the cache has 2 c blocks.
If the cache uses the set associative mapping scheme with 2 blocks per set, then
block k of the main memory maps to the set
(a) (k mod m) of the cache (b) (k mod c) of the cache
(c) (k mod 2c) of the cache (d) (k mod 2 cm) of the cache

1.23. The Newton-Raphson method is to be used to find the root of the equation f(x)=0
where
o
x is the initial approximation and f is the derivative of f. The method
converges
(a) always (b) only if f is a polynomial
(c) only if ( ) 0
o
f x < (d) None of the above

1.24. Let R = (a, b, c, d, e, f) be a relation scheme with the following dependencies
c f, e a, ec d. a b. Which of the following is a key for R?
(a) CD (b) EC (c) AE (d) AC

1.25 Which of the following is correct?
(a) B-trees are for storing data on disk and B
+
trees are for main memory.
(b) Range queries are faster on B* trees.
(c) B-trees are for primary indexes and B* trees are for secondary indexes.
(d) The height of a B* tree is independent of the number of records.

GATE CS - 1999 GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con
Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum
2. This question consists of TWENTY-FIVE sub-questions, of TWO marks each. For
each of these sub-questions, four possible alternatives (A, B, C and D) are given,
out of which ONLY ONE is correct. Indicate the correct answers in the boxes
corresponding to the questions only on the SECOND sheet of the answer book.
2.1 Consider two events E
1
and E
2
such that probability of E
1
, Pr [E
1
]=
1
,
2
probability
of E
2
, Pr
21
1
,
3
E =

and probability of E
1
and E
2
, Pr[E
1
and E
2
]=
1
.
5
Which of the
following statements is/are true?
(a)
1 2
2
Pr or is
3
E E


(b) Events E
1
and E
2
are independent
(c) Events E
1
and E
2
are not independent
(d)
1
2
4
Pr
5
E
E

=




2.2. Two girls have picked 10 roses, 15 sunflowers and 15 daffodils. What is the
number of ways they can divide the flowers amongst themselves?
(a) 1638 (b) 2100
(c) 2640 (d) None of the above

2.3. Let L be a set with a relation R which is transitive, anti-symmetric and reflexive
and for any two elements a, b L let the least upper bound lub (a,b) and the
greatest lower bound glb (a,b) exist. Which of the following is/are true?
(a) L is a poset (b) L is a Boolean algebra
(c) -L1 is context free (d) -L2 is regular

2.4. If L is context free language and L2 is a regular language which of the following
is/are false?
(a) L1 - L2 is not context free (b) L1 L2 is context free
(c) ~L1 is context free (d) ~L2 is regular

2.5. Given the programming constructs (i) assignment (ii) for loops where the loop
parameter cannot be changed within the loop (iii) if-then-else (iv) forward go to
(v) arbitrary go to (vi) non-recursive procedure call (vii) recursive
procedure/function call (viii) repeat loop, which constructs will you not include in
a programming language such that it should be possible to program the
terminates (i.e., halting) function in the same programming language.
(a) (ii), (iii), (iv)
(b) (v), (vii), (viii)
(c) (vi), (vii), (viii)
(d) (iii), (vii), (viii)
GATE CS - 1999 GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con
Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum

2.6. For the schedule given below, which of the following is correct:
1 Read
2 Read B
3 Write A
4 Read A
5 Write A
6 Write B
7 Read B
8 Write B
(a) This schedule is serialized and can occur in a scheme using 2PL protocol
(b) This schedule is serializable but cannot occur in a scheme using 2PL protocol
(c) This schedule is not serialiable but can occur in a scheme using 2PL protocol
(d) This schedule is not seralisable and cannot occur in a scheme using 2PL
protocol.

2.7. Consider the schema R = (S T U V) and the dependencies S T, T U. U V
and V S. Let R = (R1 and R2) be a decomposition such that R1 R2 = . The
decomposition is
(a) not in 2NF (b) in 2NF but not 3NF
(c) in 3NF but not in 2NF (d) in both 2NF and 3NF

2.8. Consider the circuit shown below. In a certain steady state, the line Y is at `1.
What are the possible values of A, B and c in this state?







(a) A = 0, B = 0, C = 1 (b) A = 0, B = 1, C = 1
(c) A = 1, B = 0, C = 1 (d) A = 1, B = 1, C = 1

2.9. Which of the following sets of component(s) is/are sufficient to implement any
arbitrary Boolean function?
(a) XOR gates, NOT gates
(b) 2 to 1 multiplexors
(c) AND gates, XOR gates
(d) Three-input gates that output (A.B) + C for the inputs A. B and C.
A
B
C
Y
GATE CS - 1999 GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con
Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum

2.10. A multi-user, multi-processing operating system cannot be implemented on
hardware that does not support
(a) Address translation
(b) DMA for disk transfer
(c) At least two modes of CPU execution (privileged and non-privileged)
(d) Demand paging

2.11. Which of the following is/are advantage of virtual memory?
(a) Faster access to memory on an average.
(b) Processes can be given protected address spaces.
(c) Linker can assign addresses independent of where the program will be loaded
in physical memory.
(d) Programs larger than the physical memory size can be run.

2.12. Which of the following actions is/are typically not performed by the operating
system when switching context from process A to process B?
(a) Saving current register values and restoring saved register values for process
B.
(b) Changing address translation tables.
(c) Swapping out the memory image of process A to the disk.
(d) Invalidating the translation look-aside buffer.

2.13. Consider the following program in a language that has dynamic scooping:
var x: real;
procedure show:
begin print(x);end;
procedure small;
var x: real;
begin x: = 0.125; show; end;
begin x:=0.25;
show; small
end.
Then the output of the program is:
(a) 0.125 0.125 (b) 0.25 0.25 (c) 0.25 0.125 (d) 0.125 0.25

2.14. The number of tokens in the Fortran statement DO 10 I = 1.25 is
(a) 3 (b) 4
(c) 5 (d) None of the above

GATE CS - 1999 GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con
Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum
2.15. A grammar that is both left and right recursive for a non-terminal, is
(a) Ambiguous (b) Unambiguous
(c) Information is not sufficient to decide whether it is ambiguous or
unambiguous
(d) None of the above

2.16. The number of full and half-adders required to add 16-bit numbers is
(a) 8 half-adders, 8 full-adders (b) 1 half-adder, 15 full-adders
(c) 16 half-adders, 0 full-adders (d) 4 half-adders, 12 full-adders

2.17. Zero has two representations in
(a) Sign magnitude (b) 1s complement
(c) 2s complement (d) None of the above

2.18. Raid configurations of the disks are used to provide
(a) Fault-tolerance (b) High speed
(c) high data density (d) None of the above

2.19. Arrange the following configuration for CPU in decreasing order of operating
speeds: Hard wired control, vertical microprogramming, horizontal
microprogramming.
(a) Hard wired control, vertical micro-programming, horizontal micro-
programming.
(b) Hard wired control, horizontal micro-programming, vertical micro-
programming.
(c) horizontal micro-programming, vertical micro-programming, Hard wired
control.
(d) vertical micro-programming, horizontal micro-programming, hard wired
control.

2.20. The minimum number of record movements required to merge five files A (with
10 records), B (with 20 records), C (with 15 records), D (with 5 records) and E
(with 25 records) is:
(a) 165 (b) 90 (c) 75 (d) 65

2.21. If T
1
= O(1), give the correct matching for the following pairs:

(M)
1 n n
T T n

= +
(U) ( )
n
T O n =
(N)
2
n n
T T n = +
(V) ( ) log
n
T O n n =
(O)
2
log
n n
T T n n = +
(W)
( )
2
n
T O n =
(P)
1
log
n n
T T n

= +
(X)
( )
2
log
n
T O n =
GATE CS - 1999 GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con
Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum
(a) M - W N - V O - U P - X (b) M - W N - U O - X P - V
(c) M - V N - W O - X P - U (d) M - W N - U O - V P - X

2.22. The main differences(s) between a CSIC and A RISC processor is/are that a RISC
processor typically
(a) has fewer instructions (b) has fewer addressing modes
(c) has more registers
(d) is easier to implement using hard-wired control logic

2.23. A certain processor supports only the immediate and the direct addressing
modes. Which of the following programming language features cannot be
implemented on this processor?
(a) Pointers (b) Arrays
(c) Records
(d) Recursive procedures with local variable

2.24. Consider the following C function definition
int Trial (int a, int b, int c)
{
if ((a > = b) && (c < b) return b;
else if (a > = b) return Trial (a,c,b);
else return Trial (b,a,c);
}
The function Trial:
(a) Finds the maximum of a, b, and c (b) Finds the minimum of a, b and c
(c) Finds the middle number of a, b, c

(d) None of the above

2.25. Which of the following is/are correct?
(a) An SQL query automatically eliminates duplicates
(b) An SQL query will not work if there are no indexes on the relations
(c) SQL permits attribute names to be repeated in the same relation
(d) None of the above

SECTION - B
This section consists of TWENTY questions of FIVE marks each. Attempt ANY FIFTEEN
questions. If more number of questions are attempted, score off the answer not to be
evaluated, else only the first fifteen unscored answers will be considered.
3. (a) Mr. X claims the following:
If a relation R is both symmetric and transitive, then R is reflexive. For this,
Mr. X offers the following proof:
GATE CS - 1999 GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con
Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum
"From xRy, using symmetry we get yRx. Now because R is transitive xRy and
yRx together imply xRx.
Therefore, R is reflexive.
(b) Give an example of a relation R which is symmetric and transitive but not
reflexive.

4. Let G be a finite group and H be a subgroup of G. For a G, define aH={ah1
hH).
(a) Show that |aH| = |H|
(b) Show that for every pair of elements a,b G, either aH = bH or aH and bH
are disjoint.
(c) Use the above to argue that the order of H must divide the order of G.

5. Let G be a connected, undirected graph. A cut in G is a set of edges whose
removal results in G being broken into two or more components, which are not
connected with each other. The size of a cut is called its cardinality. A min-cut of
G is a cut in G of minimum cardinality. Consider the following graph.







(a) Which of the following sets of edges is a cut?
(i) {(A, B), (E, F), (B, D), (A, E), (A, D)]
(ii) {(B, D), (C, F), (A,B)}
(b) What is the cardinality of min-cut in this graph?
(c) Prove that if a connected undirected graph G with n vertices has a min-cut of
cardinality k, then G has at least (nk/2) edges.

6. (a) Given that A is regular and (A B) is regular, does it follow that B is
necessarily regular ? Justify your answer.
(b) Given two finite automata M1, M2, outline an algorithm to decide if L(M1)
L(M2). (note: strict subset)

7. Show that the language L{xcx 1 x {0,1}* and c is a terminal symbol} is not
context free c is not 0 or 1.

8. Let Abe an n n matrix such that the elements in each row and each column are
arranged in ascending order. Draw a decision tree, which finds 1
st
, 2
nd
and 3
rd

smallest elements in minimum number of comparisons.
B
A E
F C
D
GATE CS - 1999 GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con
Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum
9. Let synthesized attribute val give the value of the binary number generated by S
in the following grammar. For example, on input 101, 101, S.val = 5.625.
S LL\L
L LB\B
B 0\1
Write S-attributed values corresponding to each of the productions to find S.val.

10. Suppose we have a function HALTS which when applied to any arbitrary function f
and its arguments will say TRUE if function f terminates for those arguments and
FALSE otherwise. Example: Given the following function definition.
FACTORIAL (N) = IF (N = 0) THEN 1 ELSE N*FACTORIAL (N-1)
Then HALTS (FACTORIAL 4) = TRUE and HALTS (FACTORIAL -5)=FALSE
Let us define the function. FUNNY (f) = IF HALTS (f f) THEN not (f f) ELSE TRUE
(a) Show that FUNNY terminates for all functions f.
(b) use (a) to prove (by contradiction) that it is not possible to have a function
like HALTS which for arbitrary functions and inputs says whether it will
terminate on that input or not.

11. (a) Consider the following algorithms. Assume, procedure A and procedure B
take ( ) (1) and ( ) (1/n) unit of time respectively. Derive the time
complexity of the algorithm in ( )-notation.
algorithm what (n)
begin
if n = 1 then call A
else begin
what (n -1);
call B(n)
end
end.
(b) Write a constant time algorithm to insert a node with data D just before the
node with address p of a singly linked list.

12. (a) In binary tree, a full node is defined to be a node with 2 children. Use
induction on the height of the binary tree to prove that the number of full
nodes plus one is equal to the number of leaves.
(b) Draw the min-heap that results from insertion of the following elements in
order into an initially empty min-heap: 7, 6, 5, 4, 3, 2, 1. Show the result
after the deletion of the root of this heap.




GATE CS - 1999 GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con
Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum
13. An instruction pipeline consists of 4 stages - Fetch (F), Decode field (D). Execute
(E) and Result Write (W). The 5 instructions in a certain instruction sequence
need these stages for the different number of clock cycles as shown by the table
below.

No. of clock cycles needed for
Instruction F D E W
1 1 2 1 1
2 1 2 2 1
3 2 1 3 2
4 1 3 2 1
5 1 2 1 2
Find the number of clock cycles needed to perform the 5 instructions.

14. (a) Show that the formual [(~pq) (q P)] is not a tautology.
(b) Let A be a tautology and B be any other formula. Prove that (AB) is a
tautology.

15. What will be the output of the following program assuming that parameter
passing is
(i) call by value
(ii) call by reference
(iii) call by copy restore
procedure P{x,y,z};
begin y: y + 1; z: x + x end;
begin
a: = : b : =3;
P(a+b,a,a);
Print (a)
end.

16. Consider the following Pascal program skeleton:
program sort (.);
var a,x,..;
procedure readarray;
vari i, ...;
begin
.:=.a.
end;
GATE CS - 1999 GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con
Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum
procedure exchange (.);
begin
.:=.a.;
.:=.x.;
end;
procedure qsort(..);
var k,v, ..;
function partition (.).;
var i,j,.;
begin
.:=.a.;
.:=.v.;
end;
begin
:
end:
begin
:
end.
Assume that given points in time during program execution, following procedures
are active: sort, qsort (1,9), qsort (1,3), partition (1,3), exchange (1,3)
Show snapshots of the runtime stack with access links after each of the
activations.

17. Consider the following program fragment in the assembly language of a certain
hypothetical processor. The processor has three general purpose registers R1, R2
and R3. The meanings of the instructions are shown by comments (starting with
;) after the instructions.

X: CMP R1,0 ; Compare R1 and 0, set flags appropriately in status
register
JZZ ; Jump if zero to target Z.
MOV R2, R1 ; Copy contents of R1 to R2
SHR R1 ; Shift right R1 by 1 bit
SHL R1 ; Shift left R1 by 1 bit
CMP R2, R1 ; Compare R2 and R1 and set flag in status register
JZY ; Jump if zero to target Y
INC R3 ; Increment R3 by 1;
Y: SHR R1 ; Shift right R1 by 1 bit
JMP X ; Jump to target X
Z:..
GATE CS - 1999 GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con
Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum
(a) Initially R1, R2 and R3 contain the values 5,0 and 0 respectively, what are
the final values of R1 and R3 when control reaches Z?
(b) In general, if R1, R2 and R3 initially contain the values n, 0, and 0
respectively. What is the final value of R3 when control reaches Z?

18. Design a 2K 8 (2048 locations, each bit wide) memory system mapped at
addresses ( ) ( )
16 16
1000 to 17FF for the 8085 processor using four 1K 4 memory
chips. Each of these chips has the following signal pins:
(i) CS (Chip select, data lines are in high impedance state when it is 1)
(ii) RD (0 for read operation)
(iii) WR(0 for write operation)
(iv) A
0
, A
1
, .A
9
(input address lines. A
0
is the lest significant)
(v) D
0
, D
1
, D
2
, D
3
(bi-directional data lines. D
0
is the least significant)

19. A certain computer system has the segmented paging architecture for virtual
memory. The memory is byte addressable. Both virtual and physical address
spaces contain
16
2 bytes each. The virtual address space is divi8ded into 8 non-
overlapping equal size segments. The memory management unit (MMU) has a
hardware segment table, each entry of which contains the physical address of the
page table for the segment. Page table are stored in the main memory and
consists of 2 byte page table entries.
(a) What is the minimum page size in bytes so that the page table for a segment
requires at most one page to store it? Assume that the page size can only be
a power of 2
(b) Now suppose that the pages size is 512 bytes. It is proposed to provide a
TLB (Translation look-aside buffer) for speeding up address translation. The
proposed TLB will be capable of storing page table entries for 16 recently
referenced virtual pages, in a fast cache that will use the direct mapping
scheme. What is the number o tag bits that will need to be associated with
each cache entry
(c) Assume that each page table entry contains (besides other information) 1
valid bit, 3 bits for page protection and 1 dirty bit. How many bits are
available in page table entry for storing the aging information for the page?
Assume that the page size is 512 bytes.

20. (a) A certain processor provides a `test and set instruction that is used as
follows.
TSET register.flag
This instruction atomically copies flag to register and sets flag to 1. Give
pseudopodia for implementing the entry and exit code to a critical region
using this instruction.
(b) Consider the following solution to the producer-consumer problem suing a
buffer of size 1. Assume that the initial value of account is 0. Also assume
that the testing of count and assignment to count are atomic operations.
GATE CS - 1999 GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con
Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum
Producer
Repeat
Produce an item;
if count = 1 then sleep;
place item in buffer.
Count =1:
Wakeup (Consumer);
Forever
Consumer:
Repeat
if count = 0 then sleep;
Remove item from buffer;
Count = 0
Wakeup (producer);
Consumer item;
Forever:
Show that in this solution it is possible that both the processes are sleeping at
the same time.

21. Consider a B-tree with degree m. that is, the number of children, c, of any
internal node (except the root) is such that m c 2m -1. derive the maximum
and minimum number of records in the leaf nodes for such a B-tree with height
h.h1. (Assume that the root of a tree is at height 0).

22. Consider the set of relations
EMP (Employee-no. Dept-no, Employee-name, Salary)
DEPT (Dept-no. Dept-name, Location)
Write an SQL query to:
(a) Find all employee names who work in departments located at `Calcutta and
whose salary is greater than Rs.50,000.
(b) Calculate, for each department number, the number of employees with a
salary greater than Rs.1,00,000.







Address: 17A, 30
th
Cross, Tilak Nagar, Jayanagar 4
th
`T Block, Bangalore - 560 041.
Ph: 080 - 51310203.







Duration: 3 Hours Maximum Marks:150


Read the following instructions carefully:

1. All answers must be written only in the answer book provided
2. This question paper consists of TWO SECTIONS: A and B.
3. Section A consists of two questions of multiple-choice type. Question 1 consists
of TWENTY-FIVE sub-questions of ONE mark each and Question 2 consists of
TWENTY-FIVE sub-questions of TWO marks each.
4. The answers to the multiple choice questions must be written only in the boxes
provided in the two sheets of the answer book.
5. There is NO NEGATIVE MARKING.
6. Section B consists of TWENTY questions of FIVE marks each. ANY FIFTEEN out of them
have to answered. If more number of questions are attempted, score off the answers not
to be evaluated, else only the first fifteen unscored will be considered strictly.
7. Question numbers must be written legibly and correctly in the answer book.
Answers to all parts of a question must appear together.
8. In all questions of 5 marks, write clearly the important steps in your answer.
These steps carry partial credit.







Website: www.gateforum.com
Email: support@gateforum.com
Centres:
Mumbai

GATE FORUM
110, Shopper's Point
1st Floor , S. V. Road
Opp. Andheri Railway Station.
Andheri (W) Mumbai.
Tel: (022) 2623 7471 / 72
Kolkata
GATE FORUM
4A, ELGIN Road
Next to Bhavanipur College
Kolkata-700020
Tel: (033) 30947075, 30947160
Jaipur
GATE FORUM
C-16 , Greater Kailash Colony,
Behind New Vidhan Sabha, Lal
Kothi, Jaipur, Rajasthan.
PIN : 302001,Tel:(0141) 5103580

Trivandrum
GATE FORUM
TC 14/ 1679 , Behind Sanskrit
College, Palayam, Trivandrum
Kerala PIN : 695034.
Tel : (471) 2322914,
Nagpur
GATE FORUM
3rd Floor, Samarth Chambers
W.H.C Road, Opp. Chauhan
Traders,
Nagpur - 440 010,
Maharashtra
Dhanbad
GATE FORUM
Flat NO: 3 B, HEM Tower,
Luby Circular Road,
Dhanbad 826001
Tel: (0326) 3108848

Durgapur
GATE FORUM
2nd floor, Nachan Road
Opposite Bank of India,
Benachity.
Durgapur - 713213
Pune
GATE FORUM
5, Kalpana Building
opp. Hotel Surya
Off Ghole Road
Pune - 411004
Tel : (020) 25538396 / 25510078
Guwahati
GATE FORUM
Maniram Dewan Road
Opposite to Regalia Marriage Hall,
Chandmari
Guwahati 781003
Tel. 91 98640 75835


Hubli / Dharwad
GATE FORUM
Plot no. 101, Shri
Venktesh Krupa,
Shiv Basav Nagar,
BELGAUM Pin 591 010
(Land mark: Naganoor swami
Kalyan Mantap
Hyderabad
GATE FORUM
Suite Number
515,Model House
Hyderabad - 82
Ph: +91-40-5583 3454
+91-40-5583 3242
GATE CS - 2000 GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con
Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum
SECTION - A
1. This question consists of TWENTY-THREE multiple questions of ONE mark each.
For each question (1.1 - 1.23), four possible alternatives (A, B, C and D) are
given, out of which ONLY ONE is correct. Indicate the correct answer in the boxes
corresponding to the questions only on the FIRST sheet of the answer book.

1.1 The minimum number of cards to be dealt from an arbitrarily shuffled deck of 52
cards to guarantee that three cards are from some same suit is
(a) 3 (b) 8 (c) 9 (d) 12

1.2 An n n array v is defined as follows:

, for all , , ,1 i j i j i j i i n j n = (



The sum of the elements of the array v is
(a) 0 (b) n -1 (c)
2
3 2 n n + (d)
( )
2
1
2
n
n
+


1.3 The determinant of the matrix

2 0 0 0
8 1 7 2
2 0 2 0
9 0 6 1
(
(
(
(
(
(

is:
(a) 4 (b) 0 (c) 15 (d) 20

1.4 Let S and T be language over ={a,b} represented by the regular expressions
(a+b*)* and (a+b)*, respectively. Which of the following is true?
(a) S T (b) T S (c) S = T (d) S T =

1.5 Let L denotes the language generated by the grammar S 0S0/00.
Which of the following is true?
(a) L = 0
+
(b) L is regular but not 0
+
(c) L is context free but not regular (d) L is not context free

1.6 The number 43 in 2s complement representation is
(a) 01010101 (b) 11010101 (c) 00101011 (d) 10101011

1.7 To put the 8085 microprocessor in the wait state
(a) lower the HOLD input (b) lower the READY input
(c) raise the HOLD input (d) raise the READY input

GATE CS - 2000 GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con
Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum
1.8 Comparing the time T1 taken for a single instruction on a pipelined CPU with time
T2 taken on a non-pipelined but identical CPU, we can say that
(a) T1 T2 (b) T1 T2 (c) T1 < T2
(d) T1 is T2 plus the time taken for one instruction fetch cycle

1.9 The 8085 microprocessor responds to the present of an interrupt
(a) as soon as the TRAP pin becomes `high
(b) by checking the TRAP pin for `high status at the end of each instruction each
(c) by checking the TRAP pin for `high status at the end of the execution of each
instruction.
(d) by checking the TRAP pin for `high status at regular intervals.

1.10 The most appropriate matching for the following pairs

X: Indirect addressing 1: Loops
Y: Immediate addressing 2: Pointers
Z: Auto decrement addressing 3. Constants
is
(a) X - 3 Y - 2 Z - 1 (b) X - 1 Y - 3 Z - 2
(c) X - 2 Y - 3 Z - 1 (d) X - 3 Y - 1 Z - 2

1.11 The following C declarations
struct node{
int i:
float j;
};
struct node *s[10];
define s to be
(a) An array, each element of which is a pointer to a structure of type node
(b) A structure of 2 fields, each field being a pointer to an array of 10 elements
(c) A structure of 3 fields: an integer, a float, and an array of 10 elements
(d) An array, each element of which is a structure of type node

1.12 The most appropriate matching for the following pairs

X: m=malloc(5); m= NULL; 1: using dangling pointers
Y: free(n); n->value=5; 2: using uninitialized pointers
Z: char *p; *p=a; 3. lost memory
GATE CS - 2000 GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con
Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum
is:
(a) X - 1 Y - 3 Z - 2 (b) X - 2 Y - 1 Z - 3
(c) X - 3 Y - 2 Z - 1 (d) X - 3 Y - 1 Z - 2

1.13 The most appropriate matching for the following pairs

X: depth first search 1: heap
Y: breadth-first search 2: queue
Z: sorting 3: stack
is:
(a) X - 1 Y - 2 Z - 3 (b) X - 3 Y - 1 Z - 2
(c) X - 3 Y - 2 Z - 1 (d) X - 2 Y - 3 Z - 1

1.14 Consider the following nested representation of binary trees: (X Y Z) indicates Y
and Z are the left and right sub stress, respectively, of node X. Note that Y and Z
may be NULL, or further nested. Which of the following represents a valid binary
tree?
(a) (1 2 (4 5 6 7)) (b) (1 (2 3 4) 5 6) 7)
(c) (1 (2 3 4)(5 6 7)) (d) (1 (2 3 NULL) (4 5))

1.15 Let s be a sorted array of n integers. Let t(n) denote the time taken for the most
efficient algorithm to determined if there are two elements with sum less than
1000 in s. which of the following statements is true?
(a) t (n) is 0(1) (b) n t(n) n log
2
n
(c) n log
2
n t(n) <
2
n | |
|
\ .
(d) t(n) =
2
n | |
|
\ .


1.16 Aliasing in the context of programming languages refers to
(a) multiple variables having the same memory location
(b) multiple variables having the same value
(c) multiple variables having the same identifier
(d) multiple uses of the same variable

1.17 Consider the following C declaration
struct {
short s [5]
union {
float y;
long z;
} u;
}t;
GATE CS - 2000 GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con
Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum
Assume that objects of the type short, float and long occupy 2 bytes, 4 bytes and
8 bytes, respectively. The memory requirement for variable t, ignoring alignment
considerations, is
(a) 22 bytes (b) 14 bytes (c) 18 bytes (d) 10 bytes

1.18 The number of tokens in the following C statement
printf("i=%d, &i=%x,i,&i);
is
(a) 3 (b) 26 (c) 10 (d) 21

1.19. Which of the following derivations does a top-down parser use while parsing an
input string? The input is assumed to be scanned in left to right order.
(a) Leftmost derivation
(b) Leftmost derivation traced out in reverse
(c) Rightmost derivation
(d) Rightmost derivation traced out in reverse

1.20. Which of the following need not necessarily be saved on a context switch
between processes?
(a) General purpose registers (b) Translation look-aside buffer
(c) Program counter (d) All of the above

1.21. Let m[0].m[4] be mutexes (binary semaphores) and P[0] .. P[4] be processes.
Suppose each process P[i] executes the following:
wait (m[i];wait (m[(i+1) mode 4]);
...
release (m[i]); release (m[(i+1)mod 4]);
This could cause
(a) Thrashing (b) Deadlock
(c) Starvation, but not deadlock (d) None of the above

1.22. B
+
-trees are preferred to binary trees in databases because
(a) Disk capacities are greater than memory capacities
(b) Disk access is much slower than memory access
(c) Disk data transfer rates are much less than memory data transfer rates
(d) Disks are more reliable than memory

1.23. Given the relations
employee (name, salary, deptno), and
department (deptno, deptname, address)
GATE CS - 2000 GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con
Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum
Which of the following queries cannot be expressed using the basic relational
algebra operations (,,, ,,,)?

(a) Department address of every employee
(b) Employees whose name is the same as their department name
(c) The sum of all employees salaries
(d) All employees of a given department

2. This question consists of TWENTY-SIX multiple questions of TWO marks each.
For each question (2.1 - 2.26), four possible alternatives (A, B, C and D) are
given, out of which ONLY ONE is correct. Indicate the correct answer in the boxes
corresponding to the questions only on the SECOND sheet of the answer book.

2.1 X,Y and Z are closed intervals of unit length on the real line. The overlap of X and
Y is half a unit. The overlap of Y and Z is also half a unit. Let the overlap of X and
Z be k units. Which of the following is true?
(a) k must be 1 (b) k must be 0
(c) k can take any value between 0 and 1 (d) None of the above

2.2. E
1
and E
2
are events in a probability space satisfying the following constraints:
Pr(E
1
) = Pr(E
2
)
Pr(E
1
E
2
) = 1
E
1
and E
2
are independent
The value of Pr(E
1
), the probability of the event E
1
, is
(a) 0 (b)
1
4
(c)
1
2
(d) 1

2.3. Let
100
2
3
log
l
i
S i
=
=

and
and T=
100
2
2
log x xdx
}

Which of the following statements is true?
(a) S > T (b) S = T
(c) S < T and 2S > T (d) 2S T

2.4. A polynomial p(x) satisfies the following:
p(1) = p(3) = p(5) = 1
p(2) = p(4) = -1
The minimum degree of such a polynomial is
(a) 1 (b) 2 (c) 3 (d) 4
GATE CS - 2000 GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con
Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum
2.5. A relation R is defined on the set of integers as x Ry iff (x+y) is even. Which of
the following statements is true?
(a) R is not an equivalence relation
(b) R is an equivalence relation having 1 equivalence class
(c) R is an equivalence relation having 2 equivalence classes
(d) R is an equivalence relation having 3 equivalence classes

2.6. Let P(S) denotes the powerset of set S. Which of the following is always true?
(a) P(P(S))=P(S) (b) P(S) P(P(S)) = {}
(c) P(S) S = P(S) (d) S P(S)

2.7. Let a, b, c, d be propositions. Assume that the equivalence a (b V-b) and b
c hold. Then the truth-value of the formula ( ) ( ) a b a c d is always
(a) True (b) False
(c) Same as the truth-value of b (d) Same as the truth-value of d

2.8. What can be said about a regular language L over {a} whose minimal finite state
automation has two states?
(a) L must be {a
n
|n is odd} (b) L must be {a
n
|n is even}
(c) L must be {a
n
|0}
(d) Either L must be {a
n
|n is odd}, or L must be {a
n
| n is even}

2.9. Consider the following decision problems:
(P1) Does a given finite state machine accept a given string
(P2) Does a given context free grammar generate an infinite number of stings
Which of the following statements is true?
(a) Both (P1) and (P2) are decidable
(b) Neither (P1) nor (P2) are decidable
(c) Only (P1) is decidable (d) Only (P2) is decidable

2.10. The simultaneous equations on the Boolean variables x, y, z and w,

1
0
1
w=0
x y z
xy
xz w
xy z
+ + =
=
+ =
+

have the following solution for x, y, z and w, respectively:
(a) 0 1 0 0 (b) 1 1 0 1 (c) 1 0 1 1 (d) 1 0 0 0


GATE CS - 2000 GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con
Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum

2.11. Which functions does NOT implement the Karnaugh map given below?

wz 00 01 11 10
xy
00 0 0 0
01 0 1 1
11 1 1 1 1
10 0 0 0

(a) ( ) w x y + (b) xy yw +
(c) ( ) ( ) ( ) w x w y x y + + + (d) None of the above

2.12. The following arrangement of master-slave flip flops




has the initial state of P, Q as 0, 1 (respectively). After the clock cycles the
output state P, Q is (respectively),
(a) 1, 0 (b) 1, 1 (c) 0, 0 (d) 0, 1

2.13. A graphics card has on board memory of 1 MB. Which of the following modes can
the card not support?
(a) 1600 400 resolution with 256 colours on a 17 inch monitor
(b) 1600 400 resolution with 16 million colours on a 14 inch monitor
(c) 800 400 resolution with 16 million colours on a 17 inch monitor
(d) 800 800 resolution with 256 colours on a 14 inch monitor

2.14. Consider the values of A = 2.0 10
30
,
B = -2.0 10
30
, C = 1.0, and the sequence
X: = A + B Y:= A + c
X: = X + C Y:= Y + B
Executed on a computer where floating point numbers are represented with 32
bits. The values for X and Y will be
(a) X = 1.0, Y = 1.0 (b) X = 1.0, Y = 0.0
(c) X = 0.0, Y = 1.0 (d) X = 0.0, Y = 0.0

P
J K
Q 1
D
1
Clock
GATE CS - 2000 GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con
Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum
2.15. Suppose you are given an array s[1.n] and a procedure reverse (s,i,j) which
reverses the order of elements in a between positions i and j (both inclusive).
What does the following sequence do, where 1 k n:
reverse (s, 1, k);
reverse (s, k + 1, n);
reverse (s, 1, n);
(a) Rotates s left by k positions (b) Leaves s unchanged
(c) Reverses all elements of s (d) None of the above

2.16. Let LASTPOST, LASTIN and LASTPRE denote the last vertex visited in a
postorder, inorder and preorder traversal. Respectively, of a complete binary
tree. Which of the following is always tree?
(a) LASTIN = LASTPOST (b) LASTIN = LASTPRE
(c) LASTPRE = LASTPOST (d) None of the above

2.17. Consider the following functions

( )
( )
( )
2
log
3
2
!
n
n n
f n n
g n
h n n
=
=
=

Which of the following is true?
(a) h(n) is O (f(n)) (b) h(n) is O (g(n))
(c) g(n) is not O (f(n)) (d) f(n) is O(g(n))

2.18. Let G be an undirected connected graph with distinct edge weight. Let
max
e be the
edge with maximum weight and
min
e the edge with minimum weight. Which of
the following statements is false?
(a) Every minimum spanning tree of G must contain
min
e
(b) If
max
e is in a minimum spanning tree, then its removal must disconnect G
(c) No minimum spanning tree contains
max
e
(d) G has a unique minimum spanning tree

2.19. Lt G be an undirected graph. Consider a depth-first traversal of G, and let T be
the resulting depth-first search tree. Let u be a vertex in G and let be the first
new (unvisited) vertex visited after visiting u in the traversal. Which of the
following statements is always true?
(a) {u,v} must be an edge in G, and u is a descendant of v in T
(b) {u,v} must be an edge in G, and v is a descendant of u in T
(c) If {u,v} is not an edge in G then u is a leaf in T
(d) If {u,v} is not an edge in G then u and v must have the same parent in T
GATE CS - 2000 GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con
Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum
2.20. The value of j at the end of the execution of the following C program
int incr (int i)
{
static int count = 0;
count = count + i;
return (count);
}
main () {
int i,j;
for (i = 0; i <=4; i++)
j = incr(i);
}
is
(a) 10 (b) 4 (c) 6 (d) 7

2.21. Given the following expression grammar:
E E * F | F + E | F
F F - | id
Which of the following is true?
(a) * has higher precedence than + (b) - has higher precedence than *
(c) + and - have same precedence (d) + has higher precedence than *

2.22. Suppose the time to service a page fault is on the average 10 milliseconds, while
a memory access takes 1 microsecond. Then a 99.99% hit ratio results in
average memory access time of
(a) 1.9999 milliseconds (b) 1 millisecond
(c) 9.999 microseconds (d) 1.9999 microseconds

2.23. Which of the following is NOT a valid deadlock prevention scheme?
(a) Release all resources before requesting a new resource
(b) Number the resources uniquely and never request a lower numbered
resource than the last one requested.
(c) Never request a resource after releasing any resource
(d) Request and all required resources be allocated before execution.






GATE CS - 2000 GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con
Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum
2.24. Given the following relation instance

1 4 2
1 5 3
1 6 3
3 2 2
X Y Z

Which of the following functional dependencies are satisfied by the instance?
(a) XY Z and Z Y (b) YZ X and Y Z
(c) YZ X and X Z

(d) XZ Y and Y X

2.25. Given relations r(w,x) and s(y,z), the result of
select distinct w,x
from r, s
is guaranteed to be same as r, provided
(a) r has no duplicates and s is non-empty
(b) r and s have no duplicates
(c) s has no duplicates and r is non-empty
(d) r and s have the same number of tuples

2.26 In SQL, relations can contain null values, and comparisons with null values are
treated as unknown. Suppose all comparisons with a null value are treated as
false. Which of the following pairs is not equivalent?
(a) x = 5 not (not (x = 5)
(b) x = 5 x > 4 and x < 6, where x is an integer
(c) x 5 not (x = 5)
(d) None of the above

SECTION - B
This section consists of TWENTY questions of FIVE marks each. Attempt ANY FIFTEEN
questions. If more number of questions are attempted, score off the answer not to be
evaluated, else only the first fifteen unscored answers will be considered.

3. Consider the following sequence: s
1
: s
2
=1 and s
1
= 1 + mine { }
1 2
,
i i
s s

for i >
2. Prove by induction on a n that
2
n
n
s
(
=
(

.

4. Let S = {0, 1, 2, 3, 4, 5, 6, 7} and denote multiplication modulo 8, that is , x
y = (xy) mod 8
(a) Prove that ({0,1}, ) is not a group.
(b) Write 3 distinct groups (G, ) where G S and G has 2 elements.
GATE CS - 2000 GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con
Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum
5. A multiset is an unordered collection of elements where elements may repeat any
number of times. The size of a multiset is the number of elements in it counting
repetitions.
(a) What is the number of multisets of size 4 that can be constructed from n
distinct elements so that at least one element occurs exactly twice?
(b) How many multisets can be consctructed from n distinct elements?

6. Let S be a set of n elements {1, 2, .., n} and G a graph with 2
n
vertices, each
vertex corresponding to a distinct subset of S. Two vertices are adjacent iff the
symmetric difference of the corresponding sets has exactly 2 elements. Note: The
symmetric difference of two sets R
1
and R
2
is defined as
1 2
2 1
R R
R R
| | | |

| |
\ . \ .

(a) Every vertex in G has the same degree. What is the degree of a vertex in G?
(b) How many connected components does G have?

7. (a) Construct as minimal finite state machine that accepts the language, over
{0,1}, of all strings that contain neither the substring 00 nor the substring
11.
(b) Consider the grammar
S aS Ab
S
A bA
A
Where S, A are non-terminal symbols with S being the start symbol; a,b are
terminal symbols and is the empty string. This grammar generates strings of
the form
i j
a b for some i, j 0, where i and j satisfy some condition. What is the
condition on the values of i and j?

8. A pushdown automaton (pda) is given in the following extended notation of finite
state diagrams:



The nodes denote the states while the edges denote the moves of the pda. The
edge labels are of the form d, / s s where d is the input symbol read and , s s are
the stack contents before and after the move. For example the edge labeled 1,
s/1.s denotes the move from state to
o o
q q in which the input symbol 1 is read
and pushed to the stack.
(a) Introduce two edges with appropriate labels in the above diagram so that the
resulting pda accepts the language
{ }
{ }
2 0,1 *, denotes revese of x ,
R R
x x x x by empty stack.
q0 q1
1.s/1.s
1,1.s/s
2.s/s
GATE CS - 2000 GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con
Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum
(b) Describe a non-deterministic pda with three states in the above notation that
accept the language
{ }
0 1 2
n m
n m n by empty stack
9. Design a logic circuit to convert a single digit BCD number to the number modulo
six as follows (Do not detect illegal input):
(a) Write the truth table for all bits. Label the input bits I
1
, I
2
, .. With I
1
as the
least significant bit. Label the output bits R
1
, R
2
, .. With R
1
as the least
significant bit. Use 1 to signify truth.
(b) Draw one circuit for each output bit using, altogether, two two-input AND
gates, one two-input gate and two NOT gates.

10. Consider the 8085 instruction IN 09H stored as follows:

Memory Address Machine Code
3050
3051
DA
09
And the following incomplete timing diagram for the instruction:








(a) Write the contents of the boxes, A, B, C and D in hexadecimal in your answer
sheet. Do not draw any pictures.
(b) Write the state of both ALE and RD pins at time units T1, T2, T3 and T4.
(c) How do you generate the signal that tells the peripheral to put the data on
the bus? Answer by completing the following statement in your answer book:
By combining signals ......

11. Consider the following 8085 program segment, where registers B and C contain
BCD values:
S1: MVI A, 99H
MVI D, 00H
SUB C
ADD B
DAA
S2: JC S3
C
30H
30H
A15-A8
T1 T2 T3 T4
T5 T6 T7 T8
T9
TA
A 50H
AD7 - AD0
D B
IO/ M
GATE CS - 2000 GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con
Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum
MOV E, A
MVI A, 99H
SUB E
MOV E, A
JZ S4
MVI D, FFH
JMP S4
S3: INC A
DAA
MOV E, A
S4: ....
(a) For the two pairs (B = 44, C = 25) and (B = 33, C = 46) at S1,
(i) Find the values in register A when control reaches S2.
(ii) Find the values in registers D and E when control reaches S4.
(b) What, in general, is the value of D and E as a function of B and C when
control reaches S4.

12. An instruction pipeline has five stages where each stage takes 2 nanoseconds
and all instructions use all five stages. Branch instructions are not overlapped,
i.e., the instruction after the branch is not fetched till the branch instruction is
completed. Under ideal conditions.
(a) Calculate the average instruction execution time assuming that 20% of all
instruction executed are branch instructions. Ignore the fact that some
branch instructions may be conditional.
(b) If a branch instruction is a conditional branch instruction, the branch need
not be taken. If the branch is not taken, the following instructions can be
overlapped. When 80% of all branch instructions are conditional branch
instructions, and 50% of the conditional branch instructions are such that the
branch is taken, calculate the average instruction execution time.

13. Suppose a stack implementation supports, in addition to PUSH and POP, an
operation REVERSE, which reverses the order of the elements on the stack.
(a) To implement a queue using the above stack implementation, show how to
implement ENQUEUE using a single operation and DEQUEUE using a
sequence of 3 operations.
(b) The following postfix expression, containing single digit operands and
arithmetic operators + and *, is evaluated using a stack.
5 2 * 3 4 + 5 2 * * +
Show the contents of the stack.
(i) After evaluating 5 2 * 3 4 +
(ii) After evaluating 5 2 * 3 4 + 5 2
(iii) At the end of evaluation.
GATE CS - 2000 GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con
Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum
14. Consider the line y = ,
n
x
m
where n and m are positive integers.
(a) If mq - np < 0, then is the point (p,q) above the line, below the line, or on
the line?
(b) Complete the following function, that returns true if the line segment with
endpoints (p,q) and (r,s) intersects the line ,
n
y x
m
= by writing the line
number and the content of each box in your answer book.
1: function clash (m, n, p, q, r, s: integer): Boolean;
2: begin
3: clash = false;
4: if (m*q - n * p) 0 then clash : = true;
5: If (m*s - n * r) 0 then clash : = true;
6: if (m*q - n * p) 0 and (m*s - n * r) 0 then clash : = true;
7: if (m*q - n * p) 0 and (m*s - n * r) 0 then clash : = true;
8: end;

15. Suppose you are given arrays p[1...N] and q[1...N] both uninitialized that is,
each location may contain an arbitrary value), and a variable count, initialized to
0. Consider the following procedures set and iset:
set (i) {
count = count + 1;
q [count] = i;
p[i] = count;
}
is_set(i) {
if (p[i] 0 or p[i] > count)
return false;
if (q[p[i]] i)
return false;
return true;
}
(a) Suppose we make the following sequence of calls:
set (7); set (3); set(9);
After these quence of calls, what is the value of count, and what do q[1],
q[2], q[3], p[7], p[3] and p[9] contain?
(b) Complete the following statement "The first count elements of _______
contain values i such that set ( __________) has been called.
(c) Show that if set (i) has not been called for some i, then regardless of what
p[i] contains, is_set (i) will return false.

GATE CS - 2000 GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con
Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum
16. A recursive program to compute Fibonacci numbers is shown below. Assume you
are also given an array f[0...m] with all elements initialized to 0.
fib(n) {
if (n > M) error ();
if ( n==0) return 1;
if (n ==1) return 1;
if ( ) _________________(1)
return ____________(2)
t = fib(n - 1) + fib (n - 2);
__________(3)
return t;
}
(a) Fill in the boxes with expressions/statements to make fib() store and reuse
computed Fibonacci values. Write the box number and the corresponding
contents in your answer book.
(b) What is the time complexity of the resulting program when computing fib(n)?

17. An array contains four occurrences of 0, five occurrences of 1, and three
occurre3nces of 2 in any order. The array is to be sorted using swap operations
(elements that are swapped need to be adjacent).
(a) What is the minimum number of swaps needed to sort such an array in the
worst case?
(b) Give an ordering of elements in the above array so that the minimum
number of swaps needed to sort the array is maximum.

18. Consider the following program is pseudo-Pascal syntax.
program main;
var x: integer;
procedure Q [z:integer);
begin
z: z + x;
writeln(z)
end;
procedure P (y:integer);
var x: integer;
begin
x: y + 2;
Q(x);
writeln(x)
end;
begin
GATE CS - 2000 GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con
Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum
x:=5;
P(x);
Q(x);
writeln(x)
end.

What is the output of the program, when
(a) The parameter passing mechanism is call-by-value and the scope rule is
static scooping?

(b) The parameter passing mechanism is call-by-reference and the scope rule is
dynamic scooping?

19. Consider the syntax directed translation scheme (SDTS) given in the following.
Assume attribute evaluation with bottom-up parsing, i.e., attributes are
evaluated immediately after a reduction.
E E
1
* T {E.val = E
1
. val * T. val}
E T {E. val = T. val}
T F - T
1
{T.val = F. val - T
1
. val}
T F {T. val = F. val}
F 2 {F. val =2}
F 4 {F. val =4}

(a) Using this SDTS, construct a parse tree for the expression
4 - 2 - 4 * 2
and also compute its E.val.

(b) It is required to compute the total number of reductions performed to parse
a given input. Using synthesized attributes only, modify the SDTS given,
without changing the grammar, to find E.red, the number of reductions
performed while reducing an input to E.

20. (a) Fill in the boxes below to get a solution for the readers-writers problem,
using a single binary semphore, mutex (initialized to 1) and busy waiting.
Write the box numbers (1,2 and 3), and their contents in your answer book.
int R = 0, W = 0;
Reader ( ) {
L1: wait (mutex);
If (W ==0) {
R = R +1;

GATE CS - 2000 GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con
Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum
_______(1)
}
else {
_______(2)
goto L1;
}
../* do the read */
wait (mutex)
R = R - 1;
signal (mutex);
}
Writer () {
L2: wait(mutex);
If ( ) { ____(3)
signal (mutex);
goto L2;
}
W=1;
signal (mutex);
../*do the write*/
wait(mutex)
W = 0;
signal (mutex);

(b) Can the above solution lead to starvation of writers?

21. (a) Suppose you are given an empty B+-tree where each node (leaf and
internal) can store up to 5 key values. Suppose values 1,2,... 10 are
inserted, in order, into the tree, Show the tree pictorially
(i) After 6 insertions, and
(ii) After all 10 insertions
Do NOT show intermediate stages.
(b) Suppose instead of splitting a node when it is full, we try to move a value to
the left sibling. If there is no left sibling, or the left sibling is full, we split the
node. Show the tree after values, 1, 2,..., 9 have been inserted. Assume, as
in (a) that each node can hold up to 5 keys.
(c) In general, suppose a B+-tree node can hold a maximum of m keys, and you
insert a long sequence of keys in increasing order. Then what approximately
is the average number of keys in each leaf level node.
(i) In the normal case, and
(ii) With the insertion as in (b).
GATE CS - 2000 GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con
Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum
22. Consider a bank database with only one relation
transaction (transno, acctno, date, amount)
The amount attribute value is positive for deposits and negative for withdrawals.

(a) Define an SQL view TP containing the information.
(acctno, T1.date, T2.amount)
for every pair of transactions T1, T2 such that T1 and T2 are transaction on
the same account and the date of T2 is the date of T1.
(b) Using only the above view TP, write a query to find for each account the
minimum balance it ever reached (not including the 0 balance when the
account is created). Assume there is at most one transaction per day on each
account, and each account has had atleast one transaction since it was
created. To simply your query, break it up into 2 steps by defining an
intermediate view V.

Address: 17A, 30
th
Cross, Tilak Nagar, Jayanagar 4
th
`T Block, Bangalore - 560 041.
Ph: 080 - 51310203.





Duration: 3 Hours Maximum Marks:150


Read the following instructions carefully:

1. This question paper consists of TWO SECTIONS: A and B.
2. Section A consists of two questions of multiple-choice type. Question 1 consists of
TWENTY-FIVE sub-questions of ONE mark each and Question 2 consists of TWENTY-
FIVE sub-questions of TWO marks each.
3. Answer Section A only on the special machine-gradable OBJECTIVE RESPONSE SHEET
(ORS). Questions in Section A will not be graded if answered elsewhere.
4. Answer problems of Section B in the answer book.
5. Write your name, registration number and name of the center at the specified locations on
the right half of the ORS for Section A.
6. Using a soft HB pencil, darken the appropriate bubble under each digit of your registration
number.
7. The ORS will be collected after 120 minutes from the start of the examination. In case you
finish Section A before the expiry of 120 minutes, you may start answering Section B.
8. Questions in Section A are to be answered by darkening the appropriate bubble (marked
A, B, C or D) using a HB pencil against the question number on the left hand side of the
ORS.
9. In case, you wish to change an answer, erase the old answer completely using a good soft
eraser.
10. There is no negative marking.
11. Section B consists of TWENTY questions of FIVE marks each. ANY FIFTEEN out of them
have to answered. If more number of questions are attempted, score off the answers not
to be evaluated, else only the first fifteen unscored will be considered strictly.
12. In all 5-mark questions (Section B), clearly show the important steps in your answers.





Website: www.gateforum.com
Email: support@gateforum.com
Centres:
Mumbai

GATE FORUM
110, Shopper's Point
1st Floor , S. V. Road
Opp. Andheri Railway Station.
Andheri (W) Mumbai.
Tel: (022) 2623 7471 / 72
Kolkata
GATE FORUM
4A, ELGIN Road
Next to Bhavanipur College
Kolkata-700020
Tel: (033) 30947075, 30947160
Jaipur
GATE FORUM
C-16 , Greater Kailash Colony,
Behind New Vidhan Sabha, Lal
Kothi, Jaipur, Rajasthan.
PIN : 302001,Tel:(0141) 5103580

Trivandrum
GATE FORUM
TC 14/ 1679 , Behind Sanskrit
College, Palayam, Trivandrum
Kerala PIN : 695034.
Tel : (471) 2322914,
Nagpur
GATE FORUM
3rd Floor, Samarth Chambers
W.H.C Road, Opp. Chauhan
Traders,
Nagpur - 440 010,
Maharashtra
Dhanbad
GATE FORUM
Flat NO: 3 B, HEM Tower,
Luby Circular Road,
Dhanbad 826001
Tel: (0326) 3108848

Durgapur
GATE FORUM
2nd floor, Nachan Road
Opposite Bank of India,
Benachity.
Durgapur - 713213
Pune
GATE FORUM
5, Kalpana Building
opp. Hotel Surya
Off Ghole Road
Pune - 411004
Tel : (020) 25538396 / 25510078
Guwahati
GATE FORUM
Maniram Dewan Road
Opposite to Regalia Marriage Hall,
Chandmari
Guwahati 781003
Tel. 91 98640 75835


Hubli / Dharwad
GATE FORUM
Plot no. 101, Shri
Venktesh Krupa,
Shiv Basav Nagar,
BELGAUM Pin 591 010
(Land mark: Naganoor swami
Kalyan Mantap
Hyderabad
GATE FORUM
Suite Number 515,Model
House
Hyderabad - 82
Ph: +91-40-5583 3454
+91-40-5583 3242
GATE CS - 2001 GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con
Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum
SECTION - A
1. This question consists of TWENTY-FIVE sub-questions (1.1 - 1.25) of ONE mark
each. For each of these sub-questions, four possible alternatives, A, B, C and D
are provided. Choose the most appropriate alternative and darken its bubble on
the Objective Response Sheet (ORS) against the corresponding sub-question
number using a soft HB pencil. Do not darken more than one bubble for any
sub-question. Do not use the ORS for any rough work. You may use the answer
book for any rough work, if needed.
1.1 Consider the following statements:
S1: The sum of two singular n n matrices may be non-singular
S2: The sum of two n n non-singular matrices may be singular.
Which of the following statements is correct?
(a) S1 and S2 are both true (b) S1 is true, S2 is false
(c) S1 is false, S2 is true (d) S1 and S2 are both false

1.2 Consider the following relations:
R1 (a,b) iff (a+b) is even over the set of integers
R2 (a,b) iff (a+b) is odd over the set of integers
R3 (a,b) iff a.b > 0 over the set of non-zero rational numbers
R4 (a,b) iff |a - b| 2 over the set of natural numbers
Which of the following statements is correct?
(a) R1 and R2 are equivalence relations, R3 and R4 are not
(b) R1 and R3 are equivalence relations, R2 and R4 are not
(c) R1 and R4 are equivalence relations, R2 and R3 are not
(d) R1, R2, R3 and R4 are all equivalence relations

1.3 Consider two well-formed formulas in prepositional logic
F1: P P F2: (PP)(PP)
Which of the following statements is correct?
(a) F1 is satisfiable, F2 is valid (b) F1 unsatisfiable, F2 is satisfiable
(c) F1 is unsatisfiable, F2 is valid (d) F1 and F2 are both satisfiable

1.4 consider the following two statements:

S1:
{ }
2
0 1
n
n is a regular language
S2:
{ }
0 1 0 1 and 1
m n m n
m n
+
is a regular language
Which of the following statements is correct?
(a) Only S1 is correct (b) Only S2 is correct
(c) Both S1 and S2 are correct (d) None of S1 and S2 is correct
GATE CS - 2001 GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con
Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum
1.5 Which of the following statements s true?
(a) If a language is context free it can always be accepted by a deterministic
push-down automaton
(b) The union of two context free languages is context free
(c) The intersection of two context free languages is context free
(d) The complement of a context free language is context free

1.6 Given an arbitary non-deterministic finite automaton (NFA) with N states, the
maximum number of states in an equivalent minimized DFA is at least
(a) N
2
(b) 2
N
(c) 2N (d) N!

1.7 More than one word are put in one cache block to
(a) exploit the temporal locality of reference in a program
(b) exploit the spatial locality of reference in a program
(c) reduce the miss penalty
(d) none of the above

1.8 Which of the following statements is false?
(a) Virtual memory implements the translation of a programs address space into
physical memory address space
(b) Virtual memory allows each program to exceed the size of the primary
memory
(c) Virtual memory increases the degree of multiprogramming
(d) Virtual memory reduces the context switching overhead

1.9 A low memory can be connected to 8085 by using
(a) INTER (b) RESET IN (c) HOLD (d) READY

1.10 Suppose a processor does not have any stack pointer register. Which of the
following statements is true?
(a) It cannot have subroutine call instruction
(b) It can have subroutine call instruction, but no nested subroutine calls
(c) Nested subroutine calls are possible, but interrupts are not
(d) All sequences of subroutine calls and also interrupts are possible






GATE CS - 2001 GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con
Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum
yz
wx

1.11 Given the following Karnaugh map, which one of the following represents the
minimal Sum-Of-Products of the map?









(a) xy y z + (b) wx y xy xz + + (c) wx y z xy + + (d) xz+y

1.12 A processor needs software interrupt to
(a) test the interrupt system of the processor
(b) implement co-routines
(c) obtain system services which need execution of privileged instructions
(d) return from subroutine

1.13 A CPU has two modes-privileged and non-privileged. In order to change the mode
from privileged to non-privileged
(a) a hardware interrupt is needed
(b) a software interrupt is needed
(c) a privileged instruction (which does not generate an interrupt) is needed
(d) a non-privileged instruction (which does not generate an interrupt is needed

1.14 Randomized quicksort is an extension of quicksort where the pivot is chosen
randomly. What is the worst case complexity of sorting n numbers using
randomized quicksort?
(a) O(n) (b) O(n log n) (c) O(n
2
) (d) O(n!)

1.15 Consider any array representation of an n element binary heap where the
elements are stored from index 1 to index n of the array. For the element stored
at index i of the array (in), the index of the parent is
(a) i-1 (b)
2
i
(c)
2
i
(d)
( ) 1
2
i +



00 01 11 10
00 0 X 0 X
01 X 1 X 1
11 0 X 1 0
10 0 1 X 0
GATE CS - 2001 GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con
Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum
1.16 Let ( ) ( ) ( )
10
2
log and log f n n n g n n n = = be two positive functions of n. Which of
the following statements is correct?
(a) f(n) = O(g(n) and g(n) O(f(n)) (b) g(n) = O(f(n) and f(n) O(g(n))
(c) f(n)O(g(n)) and g(n) O(f(n)) (d) f(n)=O(g(n)) and g(n) =O(f(n))

1.17 The process of assigning load addresses to the various parts of the program and
adjusting the code and date in the program to reflect the assigned addresses is
called
(a) Assembly (b) Parsing
(c) Relocation (d) Symbol resolution

1.18 Which of the following statements is false?
(a) An unambiguous grammar has same leftmost and rightmost derivation
(b) An LL(1) parser is a top-down parser
(c) LALR is more powerful than SLR
(d) An ambiguous grammar can never be LR(k) for any k

1.19 Consider a set of n tasks with known runtimes r
1
, r
2
, .. r
n
to be run on a
uniprocessor machine. Which of the following processor scheduling algorithms will
result in the maximum throughput?
(a) Round-Robin (b) Shortest-Job-First
(c) Highest-Response-Ratio-Next (d) First-Come-First-Served

1.20 Where does the swap space reside?
(a) RAM (b) Disk
(c) ROM (d) On-chip cache

1.21 Consider a virtual memory system with FIFO page replacement policy. For an
arbitrary page access pattern, increasing the number of page frames in main
memory will
(a) always decrease the number of page faults
(b) always increase the number of page faults
(c) sometimes increase the number of page faults
(d) never affect the number of page faults

1.22 Which of the following requires a device driver?
(a) Register (b) Cache (c) Main memory (d) Disk



GATE CS - 2001 GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con
Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum
1.23 Consider a schema R(A,B,C,D) and functional dependencies A B and C D.
Then the decomposition of R into R
1
(AB) and R
2
(CD) is
(a) dependency preserving and lossless join
(b) lossless join but not dependency preserving
(c) dependency preserving but not lossless join
(d) not dependency preserving and not lossless join

1.24 Suppose the adjacency relation of vertices in a graph is represented in a table
Adj (X,Y). Which of the following queries cannot be expressed by a relational
algebra expression of constant length?
(a) List of all vertices adjacent to a given vertex
(b) List all vertices which have self loops
(c) List all vertices which belong to cycles of less than three vertices
(d) List all vertices reachable from a given vertex

1.25 Let r and s be two relations over the relation schemes R and S respectively, and
let A be an attribute in R. then the relational algebra expression
A a

=
(r s) is
always equal to
(a)
A a

=
(r) (b) r
(c)
A a

=
(r) s (d) None of the above

2. This question consists of TWENTY-FIVE sub-questions (2.1 - 2.25) of TWO marks
each. For each of these sub-questions, four possible alternatives, A,B, C and D
are provided. Choose the most appropriate alternative and darken its bubble on
the Objective Response Sheet (ORS) against the corresponding sub-question
number using a soft HB pencil. Do not darken more than one bubble for any
sub-question. Do not use the ORS for any rough work. You may use the answer
book for any rough work, if needed.

2.1 How many 4-digit even numbers have all 4 digits distinct?
(a) 2240 (b) 2296 (c) 2620 (d) 4536

2.2 Consider the following statements:
S1: There exists infinite sets A, B, C such that A(BC) is finite.
S2: There exists two irrational numbers x and y such that (x+y) is rational.
Which of the following is true about S1 and S2?
(a) Only S1 is correct (b) Only S2 is correct
(c) Both S1 and S2 are correct (d) None of S1 and S2 is correct



GATE CS - 2001 GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con
Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum
2.3 Let f: A B be a function, and let E and F be subsets of A. Consider the following
statements about images.
S1:f(EF)=f(E) f(F)
S2:f(EF)=f(E) f(F)
Which of the following is true about S1 and S2?
(a) Only S1 is correct (b) Only S2 is correct
(c) Both S1 and S2 are correct (d) None of S1 and S2 is correct

2.4 Seven (distinct) car accidents occurred in a week. What is the probability that
they all occurred on the same day?
(a)
7
1
7
(b)
6
1
7
(c)
7
1
2
(d)
7
7
2


2.5 Consider a DFA over { } , a b =

accepting all strings which have number of as


divisible by 6 and number of bs divisible by 8. What is the minimum number of
states that the DFA will have?
(a) 8 (b) 14 (c) 15 (d) 48

2.6 Consider the following languages:
{ }
{ }
1 , * L ww w a b =
{ }
{ }
2 , *, is the reverse of w
R R
L ww w a b w =

{ }
2
3 0 i is an integer
i
L =

{ }
2
3 0 i is an integer
i
L =
Which of the languages are regular?
(a) Only L1 and L2 (b) Only L2, L3 and L4
(c) Only L3 and L4 (d) Only L3

2.7 Consider the following problem X.
Given a Turing machine M over the input alphabet , any state q of M
And a word w *, does the computation of M on w visit the state q?
Which of the following statements about X is correct?
(a) X is decidable
(b) X is undecidable but partially decidable
(c) X is undecidable and not even partially decidable
(d) X is not a decision problem

GATE CS - 2001 GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con
Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum
2.8 Consider the following circuit with initial state Q
0
= Q
1
= 0. The D Flip-flops are
positive edged triggered and have set up times 20 nanosecond and hold times 0.








Consider the following timing diagrams of X and C; the clock period of C40
nanosecond. Which one is the correct plot of Y?







(a)

(b)

(c)

(d)


2.9 Which is the most appropriate match for the items in the first column with the
items in the second column

X. Indirect Addressing I. Array implementation
Y. Indexed Addressing II. Writing re-locatable code
Z. Base Register Addressing III. Passing array as parameter

(a) (X, III) (Y, I) (Z, II) (b) (X, II) (Y, III) (Z, I)
(c) (X, III) (Y, II) (Z, I) (d) (X, I) (Y, III) (Z, II)

Y
C
X D0
Clock
Clock
D1
Q1
0
Q
C
X
GATE CS - 2001 GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con
Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum
2.10 The 2s complement representation of ( )
10
539 is hexadecimal is
(a) ABE (b) DBC (c) DE5 (d) 9E7

2.11 Consider the circuit shown below. The output of a 2:1 Mux is given by the
function ( ). ac bc +








Which of the following is true?
(a) 1 2 f x x = + (b) 1 2 1 2 f x x x x = +
(c) 1 2 1 2 f x x x x = + (d) 1 2 f x x = +

2.12 Consider the circuit given below with initial state Q
0
=1, Q
1
= Q
2
= 0. The state of
the circuit is given by the value
2 1 0
4 2 Q Q Q + +










Which one of the following is the correct state sequence of the circuit?
(a) 1,3,4,6,7,5,2 (b) 1,2,5,3,7,6,4 (c) 1,2,7,3,5,6,4 (d) 1,6,5,7,2,3,4







a
b
c
a
b
c
MUX
MUX
2:1
2:1
g
x1
x2
1
0
f
D0
Q0 D1 Q1 D2
Q2
LSB MSB
Clock
GATE CS - 2001 GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con
Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum
2.13 Consider the following data path of a simple non-pilelined CPU. The registers A,
B, A
1
, A
2
, MDR, the bus and the ALU are 8-bit wide. SP and MAR are 16-bit
registers. The MUX is of size 8 (2:1) and the DEMUX is of size 8 (1:2). Each
memory operation takes 2 CPU clock cycles and uses MAR (Memory Address
Register) and MDR (Memory Date Register). SP can be decremented locally.












The CPU instruction "push r, where = A or B, has the specification
M [SP] r
SP SP - 1
How many CPU clock cycles are needed to execute the "push r instruction?
(a) 2 (b) 3 (c) 4 (d) 5

2.14 Consider an undirected unweighted graph G. Let a breadth-first traversal of G be
done starting from a node r. Let d(r,u) and d(r,v) be the lengths of the shortest
paths from r to u and v respectively in G. If u is visited before v during the
breadth-first traversal, which of the following statements is correct?
(a) d(r,u)<d(r,v) (b) d(r,u)>d(r,v)
(c) d(r,u)d(r,v) (d) None of the above

2.15 How many undirected graphs (not necessarily connected) can be constructed out
of a given set { }
1 2
, ,
n
V v v v = of n vertices?
(a)
( ) 1
2
n n
(b) 2
n
(c) n! (d)
( ) 1
2
2
n n


2.16 What is the minimum number of stacks of size n required to implement a queue
of size n?
(a) One (b) Two (c) Three (d) Four


A2
A1
B A
MUX
1:2
DEMUX
1:2
MAR MDR SP dcr
GATE CS - 2001 GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con
Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum
2.17 What is printed by the print statements in the program P1 assuming call by
reference parameter passing?
Program P1()
{
x=10;
y=3;
func1(y,x,x);
print x;
print y;
}
func1(x,y,z)
{
y=y+4;
z=x+y+z;
}
(a) 10, 3 (b) 31, 3
(c) 27, 7 (d) None of the above

2.18 Consider the following three C functions:
[P1] int*g(void)
{
intx=10;
return(&x);
}

[P2] int*g(void)
{
int*px;
*px=10;
return px;
}
[P3] int*g(void)
{
int*px
px =(int*)malloc (size of (int));
*px=10;
return px;
}

GATE CS - 2001 GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con
Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum
Which of the above three functions are likely to cause problems with pointers?
(a) Only P3 (b) Only P1 and P3
(c) Only P1 and P2 (d) P1, P2 and P3

2.19 Consider the following program
Program P2
var n:int:
procedure W(var x:int)
begin
x=x+1;
printx;
end

procedure D
begin
var n:int;
n=3;
W(n);
End
begin \\begin P2
n = 10;
D;
end
If the language has dynamic scooping and parameters are passed by reference,
what will be printed by the program?
(a) 10 (b) 11 (c) 3
(d) None of the above

2.20 Which of the following does not interrupt a running process?
(a) A device (b) Timer
(c) Scheduler process (d) Power failure

2.21 Consider a machine with 64 MB physical memory and a 32-bit virtual address
space. If the page size is 4KB, what is the approximate size of the page table?
(a) 16 MB (b) 8 MB (c) 2 MB (d) 24 MB




GATE CS - 2001 GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con
Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum
2.22 Consider Petersons algorithm for mutual exclusion between two concurrent
processes i and j. The program executed by process is shown below.
repeat
flag[i]=true;
turn=j;
while (P) do no-op;
Enter critical section, perform actions, then
exit critical section
Flag[i]=false;
Perform other non-critical section actions.
Until false;
For the program to guarantee mutual exclusion, the predicate P in the while loop
should be
(a) flag[j]=true and turn=i (b) flag[j]=true and turn=j
(c) flag[i]=true and turn=j (d) flag[i]=true and turn=i

2.23 R(A,B,C,D) is a relation. Which of the following does not have a lossless join,
dependency preserving BCNF decomposition?
(a) A B, B CD (b) A B, B C, C D
(c) AB C, C AD (d) A BCD

2.24 Which of the following relational calculus expressions is not safe?
(a)
( ) ( )
{ } 1 2
t u R t A u A s R t A s A = =


(b)
( ) ( )
{ } 1 2
" " t u R u A x s R t A s A s A u A = = =


(c) ( )
{ } 1
t t R
(d)
( ) ( )
{ } 1 2
t u R t A u A s R t A s A = =



2.25 Consider a relation geq which represents "greater than or equal to, that is,
(x,y) geq only if yx.
create table geq
( Ib integer not null
ub integer not null
primary key 1b
foreign key (ub) references geq on delete cascade )
Which of the following is possible if a tuple (x,y) is deleted?
(a) A tuple (z,w) with z > y is deleted
(b) A tuple (z,w) with z > x is deleted
GATE CS - 2001 GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con
Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum
(c) A tuple (z,w) with w < x is deleted
(d) The deletion of (x,y) is prohibited

SECTION B

This section consists of TWENTY questions of FIVE marks each. Any FIFTEEN out of
these questions have to be answered on the Answer Book provided.

3. (a) prove that powerset ( ) A B = powerset(A)powerset(B)
(b) Let sum(n)=0+1+2+...+n for all natural numbers n. give an induction proof
to show that the following equation is true for all natural numbers m and n:
sum(m+n)=sum(m)+sum(n)+mn

4. Consider the function h: NN N so that h (a,b) = ( ) 2 1 2 1,
b
a + where N
={0,1,2,3,...} is the set of natural numbers.
(a) Prove that the function h is an injection (one-one).
(b) Prove that it is also a Subjection (onto)

5. Construct DFAs for the following languages:
(a) { }
{ }
, *, w has baab as a subsring L w w a b =
(b) { }
{ }
, *, w has an odd number of a's and an odd nuber of b's L w w a b =

6. Give a deterministic PDA for the language
{ }
2
1
n n
L a cb n = over the alphabet =
{ } , , . a b c =

Specify the acceptance state.






7. Let a decision problem X be defined as follows:
X: Given a Turing machine M over and nay word w ,
does M loop forever on w?
You may assume that the halting problem of Turing machine is undecidable but
partially decidable.
(a) Show that X is undecidable.
(b) Show that X is not even partially decidable.


GATE CS - 2001 GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con
Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum
8. Consider a disk with following specifications: 20 surface, 1000 tracks/surface, 16
sectors/track, data density 1 KB/sector, rotation speed 3000 rpm. The operating
system initiates the transfer between the disk and the memory sector-wise. Once
the head has been placed on the right track, the disk reads a sector in a single
scan. It reads bits from the sector while the head is passing over the sector. The
read bits are formed into bytes in a serial-in-parallel-out buffer and each byte is
then transferred to memory. The disk writing is exactly a complementary
process.
For parts (c) and (d) below, assume memory read-write time = 0.1 micro-
second/byte, interrupt driven transfer has an interrupt overhead = 0.4
microseconds, the DMA initialization and termination overhead is negligible
compared to the total sector transfer time. DMA requests are always granted.
(a) What is the total capacity of the disk?
(b) What is the data transfer rate?
(c) What is the percentage of time the CPU is required for this disk I/O for byte-
wise interrupts driven transfer?
(d) What is the maximum percentage of time the CPU is held up for this disk I/O
for cycle-stealing DMA transfer?

9. A CPU has 32-bit memory address and a 256 KB cache memory. The cache is
organized as a 4-way set associative cache with cache block size of 16 bytes.
(a) What is the number of sets in the cache?
(b) What is the size (in bits) of the tag field per cache block?
(c) What is the number and size of comparators required for tag matching?
(d) How many address bits are required to find the byte offset within a cache
block?
(e) What is the total amount of extra memory (in bytes) required for the tag
bits?

10. (a) Is the 3-variable function ( ) 0,1,2, 4 f =

its self-dual? Justify your answer.
(b) Give a minimal product-of-sum form of the b output of the following excess-3
to BCD converter.




11. A sequential circuit takes an input stream of 0s and 1s and produces an output
stream of 0s and 1s. Initially it replicates the input on its output until two
consecutive 0s are encountered on the input. From then onward, it produces an
output stream, which is the bit-wise complement of input stream until it
encounters two consecutive 1s, whereupon the process repeats. An example of
input and output stream is shown below.

e8
e4
e2
e1
b8
b4
b2
b1
Excess 3
To BCD
GATE CS - 2001 GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con
Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum

The input stream: 101100 01001011 0 11
The desired output: 101100 10110100 0 11

J-K master-slave flip-flops are to be used to design the circuit.
(a) Give the state transition diagram.
(b) Give the minimized sum-of-product expression for J and K inputs of one of its
state flip-flops.

12. Consider a 5-stage pipeline - IF (Instruction Fetch), ID (Instruction Decode and
register read), EX (Execute), MEM (memory), and WB (Write Back). All (memory
or register) reads take place in the second phase of a clock cycle and writes occur
in the first phase of the clock cycle. Consider the execution of the following
instruction sequence:
11: sub r2, r3, r4; /* r2 r3 - r4 */
12: sub r4, r2, r3; /* r4 r2 - r3 */
13: sw r2, 100(r1) /* M[r1+100] r2 */
14: sub r3, r4, r2; /* r3 r4 - r2 */
(a) Show all data dependencies between the four instructions.
(b) Identify the data hazards.
(c) Can all hazards be avoided by forwarding in this case?

13. Consider the following C program:
void abc(char*s)
{
if(s[0]==\0)return;
abc(s+1);
abc(s+1);
printf("%c,s[0]);
}
main()
{ abc("123)
}
(a) What will be the output of the program?
(b) If abc(s) is called with a null-terminated string s of length n characters (not
counting the null (`\0) character), how many characters will be printed by
abc(s)?

14. (a) Insert the following keys one by one into a binary search tree in the order
specified.
15, 32, 20, 9, 3, 25, 12, 1
Show the final binary search tree after the insertions.
GATE CS - 2001 GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con
Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum
(b) Draw the binary search tree after deleting 15 from it.
(c) Complete the statements S1, S2 and S3 in the following function so that the
function computes the depth of a binary rooted at t.
typedef struct tnode{
int key;
struct tnode *left, *right;
} *Tree;
int depth(Tree t)
{
int x,y;
it (t ==NULL) return0;
x=depth(t left);
S1: ____________;
S2: if(x>y) return _____________:
S3: else return _____________;
}

15. Consider a weighted undirected graph with vertex set V = {n1,n2,n3,n4,n5,n6}
and edge set
E={(n1,n2,2),(n1,n3,8),(n1,n6,3),(n2,n4,4),(n2,n5,12),(n3,n4,7),(n4,n5,9),
(n4,n6,4)}. The third value in each tuple represents the weight of the edge
specified in the tuple.
(a) List the edges of a minimum spanning tree of the graph.
(b) How many distinct minimum spanning trees does this graph have?
(c) Is the minimum among the edge weights of a minimum spanning tree unique
overall possible minimum spanning trees of a graph?
(d) Is the maximum among the edge weights of a minimum spanning tree
unique over all possible minimum spanning trees of a graph?

16. Consider the following grammar with terminal alphabet { } ,(, ), ,* a +

and start
symbol E. The production rules of the grammar are:
E aA
E (E)
A +E
A *E
A
(a) Compute the FIRST and FOLLOW sets for E and A.
(b) Complete the LL(1) parse table for the grammar.


GATE CS - 2001 GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con
Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum
17. The syntax of the repeat-until statement is given by the following grammar
S repeat S
1
until E
Where E stands for expressions, S and S
1
stand for statement. The non-terminals
S and S
1
have an attribute code that represents generated code. The non-
terminal E has two attributes. The attribute code represents generated code to
evaluate the expression and store its truth value in a distinct variable, and the
attribute varName contains the name of the variable in which the truth value is
stored? The truth-value stored in the variable is 1 if E is true, 0 if E is false.
Give a syntax-directed definition to generate three-address code for the repeat-
until statement. Assume that you can call a function newlabel( ) that returns a
distinct label for a statement. Use the operator `\\ to concatenate two strings and
the function gen(s) to generate a line containing the string s.

18. (a) Remove left-recursion from the following grammar:
S Sa| Sb | a | b
(b) Consider the following grammar:
S aSbS| bSaS |
Construct all possible parse trees for the string abab. Is the grammar
ambiguous?

19. Two concurrent processes P1 and P2 want to use two resources R1 and R2 in a
mutually exclusive manner. Initially, R1 and R2 are free. The programs executed
by the two processes are given below.
Program for P1:
S1: While (R1 is busy) do no-op;
S2: Set R1 busy;
S3: While (R2 is busy) do no-op;
S4: Set R2 busy;
S5: Use R1 and R2;
S6: Set R1 free;
S7: Set R2 free;
Program for P2:
Q1: While (R1 is busy) do no-op;
Q2: Set R1 busy;
Q3: While (R1 is busy) do no-op;
Q4: Set R1 busy;
Q5: Use R1 and R2;
Q6: Set R2 free;
Q7: Set R1 free;

GATE CS - 2001 GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con
Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum
(a) Is mutual exclusion guaranteed for R1 and R2? If not, show a possible
interleaving of the statements of P1 and P2 such that mutual exclusion is
violated (i.e., both P1 and P2 use R1 or R2 at the same time).
(b) Can deadlock occur in the above program? If yes, show a possible
interleaving of the statements of P1 and P2 leading to deadlock.
(c) Exchange the statements Q1 and Q3 and statements Q2 and Q4. Is mutual
exclusion guaranteed now? Can deadlock occur?

20. Consider a disk with the 100 tracks numbered from 0 to 99 rotating at 3000 rpm.
The number of sectors per track is 100. the time to move the head between two
successive tracks is 0.2 millisecond.
(a) Consider a set of disk requests to read data from tracks 32, 7, 45, 5 and 10.
Assuming that the elevator algorithm is used to schedule disk requests, and
the head is initially at track 25 moving up (towards larger track numbers),
what is the total seek time for servicing the requests?
(b) Consider an initial set of 100 arbitrary disk requests and assume that no new
disk requests arrive while servicing these requests. If the head is initially at
track 0 and the elevator algorithm is used to schedule disk requests, what is
the worst case time to complete all the requests?

21. Consider the relation examinee (regno, name, score), where regno is the primary
key to score is a real number.
(a) Write a relational algebra using (,,,) to find the list of names which
appear more than once in examinee.
(b) Write an SQL query to list the regno of examinees who have a score greater
than the average score.
(c) Suppose the relation appears (regno, centr_code) specifies the center where
an examinee appears. Write an SQL query to list the centr_code having an
examinee of score greater than 80.

22. We wish to construct a B
+
tree with fan-out (the number of pointers per node)
equal to 3 for the following set of key values:
80, 50, 10, 70, 30, 100, 90
Assume that the tree is initially empty and the values are added in the order
given.
(a) Show the tree after insertion of 10, after insertion of 30, and after insertion
of 90. Intermediate trees need not be shown.
(b) The key values 30 and 10 are now deleted from the tree in that order. Show
the tree after each deletion.

Address: 17A, 30
th
Cross, Tilak Nagar, Jayanagar 4
th
`T Block, Bangalore - 560 041.
Ph: 080 - 51310203.





Duration: 3 Hours Maximum Marks:200


Read the following instructions carefully:

1. All answers must be written in ENGLISH.
2. This question paper consists of TWO SECTIONS: A and B.
3. Section A consists of two questions of multiple choice type. Question 1 consists of TWENTY-FIVE
sub-questions of ONE mark each and Question 2 consists of TWENTY-FIVE sub-questions of TWO
marks each.
4. Answer Section A only on the special machine-gradable OBJECTIVE RESPONSE SHEET (ORS).
Questions in Section A will not be graded if answered elsewhere.
5. Write your name, registration number and the name of the Centre at the specified locations ont eh
right half of the ORS for Section A.
6. Using a HB pencil, darken the appropriate bubble under each digit of your registration number.
7. Questions in Section A are to be answered by darkening the appropriate bubble (marked A, B, C or D)
using a HB pencil against the question number on the left hand side of the ORS. In case, you wish to
change an answer, erase the old answer completely using a good soft eraser.
8. The ORS will be collected after 120 minutes from the start of the examination. In case you finish
Section A before the expiry of 120 minutes, you may start answering Section B.
9. There will be NEGATIVE marking in Section A. For each wrong answer to 1 and 2 mark sub-questions,
0.25 and 0.5 marks will be deducted respectively. More than one answer marked against a question
will be deemed as an incorrect response and will be negatively marked.
10. Answer questions in Section B in the answer book. Section B consists of TWENTY questions of FIVE
marks each. ANY FIFTEEN out of them have to answered. If more number of questions are attempted,
score off the answers not to be evaluated, else only the first fifteen unscored will be considered
11. Answer for each question in Section B should be started on a fresh page. Questions numbers must be
written legibly and correctly in the answer book.
12. In all 5-mark questions (Section B), clearly show the important steps in your answers. These
intermediate steps will carry partial credit.






Website: www.gateforum.com
Email: support@gateforum.com
Centres:
Mumbai

GATE FORUM
110, Shopper's Point
1st Floor , S. V. Road
Opp. Andheri Railway Station.
Andheri (W) Mumbai.
Tel: (022) 2623 7471 / 72
Kolkata
GATE FORUM
4A, ELGIN Road
Next to Bhavanipur College
Kolkata-700020
Tel: (033) 30947075, 30947160
Jaipur
GATE FORUM
C-16 , Greater Kailash Colony,
Behind New Vidhan Sabha, Lal
Kothi, Jaipur, Rajasthan.
PIN : 302001,Tel:(0141) 5103580

Trivandrum
GATE FORUM
TC 14/ 1679 , Behind Sanskrit
College, Palayam, Trivandrum
Kerala PIN : 695034.
Tel : (471) 2322914,
Nagpur
GATE FORUM
3rd Floor, Samarth Chambers
W.H.C Road, Opp. Chauhan
Traders,
Nagpur - 440 010,
Maharashtra
Dhanbad
GATE FORUM
Flat NO: 3 B, HEM Tower,
Luby Circular Road,
Dhanbad 826001
Tel: (0326) 3108848

Durgapur
GATE FORUM
2nd floor, Nachan Road
Opposite Bank of India,
Benachity.
Durgapur - 713213
Pune
GATE FORUM
5, Kalpana Building
opp. Hotel Surya
Off Ghole Road
Pune - 411004
Tel : (020) 25538396 / 25510078
Guwahati
GATE FORUM
Maniram Dewan Road
Opposite to Regalia Marriage Hall,
Chandmari
Guwahati 781003
Tel. 91 98640 75835


Hubli / Dharwad
GATE FORUM
Plot no. 101, Shri
Venktesh Krupa,
Shiv Basav Nagar,
BELGAUM Pin 591 010
(Land mark: Naganoor swami
Kalyan Mantap
Hyderabad
GATE FORUM
Suite Number 515,Model
House
Hyderabad - 82
Ph: +91-40-5583 3454
+91-40-5583 3242
GATE CS - 2002 GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con
Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum
SECTION A
1. This question consists of TWENTY-FIVE sub-questions (1.1 - 1.25) of ONE mark
each. For each of these sub-questions, four possible alternatives, A, B, C and D
are provided. Choose the most appropriate alternative and darken its bubble on
the Objective Response Sheet (ORS) against the corresponding sub-question
number using a soft HB pencil. Do not darken more than one bubble for any
sub-question. Do not use the ORS for any rough work. You may use the answer
book (last few pages) for any rough work.

1.1 The rank of the matrix
1 1
0 0
(
(

is
(a) 4 (b) 2 (c) 1 (d) 0

1.2 The trapezoidal rule for integration gives exact result when the integrand is a
polynomial of degree
(a) 0 but not 1 (b) 1 but not 0 (c) 0 or 1 (d) 2

1.3 The solution to the recurrence equation
( ) ( )
( )
1
2 3 2 1, 1 1
k k
T T T

= + = is
(a) 2
k
(b)
( )
1
3 1
2
k +

(c)
2
log
3
k
(d)
3
log
2
k


1.4 The minimum number of colours required to colour the vertices of a cycle with n
nodes in such a way that no two adjacent nodes have the same colour is

(a) 2 (b) 3 (c) 4 (d) 2 2
2
n
n
(
+
(



1.5 In the worst case, the number of comparisons needed to search a singly linked
list of length n for a given element is
(a) log n (b)
2
n
(c)
2
log 1
n
(d) n

1.6 Which of the following is true?
(a) The set of all rational negative numbers forms a group under multiplication.
(b) The set of all non-singular matrices forms a group under multiplication.
(c) The set of all matrices forms a group under multiplication.
(d) Both B and C are true.

1.7 The language accepted by a Pushdown Automaton in which the stack is limited to
10 items is best described as
(a) Context free (b) Regular
(c) Deterministic Context free (d) Recursive
GATE CS - 2002 GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con
Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum
1.8 "If X then Y unless Z is represented by which of the following formulas in
prepositional logic? (" ", is negation, " is conjunction, and " is implication)
(a) (XZ)Y (b) (XY)Z (c) X(YZ) (d) (XY)Z

1.9 A device employing INTR line for device interrupt puts the CALL instruction on the
data bus while
(a) INTA is active (b) HOLD is active
(c) READY is active (d) None of the above

1.10 In 8085 which of the following modifies the program counter?
(a) Only PCHL instruction (b) Only ADD instructions
(c) Only JMP and CALL instructions (d) All instructions

1.11 In serial data transmission, every byte of data is padded with a `0 in the
beginning and one or two `1s at the end of byte because
(a) Receiver is to be synchronized for byte reception
(b) Receiver recovers lost `0s and `1s from these padded bits
(c) Padded bits are useful in parity computation
(d) None of the above

1.12 Minimum sum of product expression for f(w,x,y,z) shown in Karnaugh-map below
is









(a) xz y z + (b) xz zx +
(c) x y zx + (d) None of the above

1.13 Which of the following is not a form of memory?
(a) instruction cache (b) instruction register
(c) instruction opcode (d) translation look-a-side buffer


00 01 11 10
00
01
11
10
wx
yz
0 1 1 0
0 0 1 x
x 0 0 1
x 0 1 1
GATE CS - 2002 GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con
Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum

1.14 The decimal value 0.25
(a) is equivalent to the binary value 0.1
(b) is equivalent to the binary value 0.01
(c) is equivalent to the binary value 0.00111.
(d) cannot be represented precisely in binary

1.15 The 2s complement representation of the decimal value -15 is
(a) 1111 (b) 11111 (c) 111111 (d) 10001

1.16 Sign extension is a step in
(a) floating point multiplication
(b) signed 16 bit integer addition
(c) arithmetic left shift
(d) converting a signed integer from one size to another

1.17 In the C language
(a) At most one activation record exists between the current activation record
and the activation record for the main
(b) The number of activation records between the current activation record and
the activation record fro the main depends on the actual function calling
sequence.
(c) The visibility of global variables depends on the actual function calling
sequence.
(d) Recursion requires the activation record for the recursive function to be
saved on a different stack before the recursive fraction can be called.

1.18 The results returned by function under value-result and reference parameter
passing conventions
(a) Do not differ
(b) Differ in the presence of loops
(c) Differ in all cases
(d) May differ in the presence of exception

1.19 Relation R with an associated set of functional dependencies, F, is decomposed
into BCNF. The redundancy (arising out of functional dependencies) in the
resulting set of relations is
(a) Zero
(b) More than zero but less than that of an equivalent 3NF decomposition
(c) Proportional to the size of F
+

(d) Indetermine
GATE CS - 2002 GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con
Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum
1.20 With regard to the expressive power of the formal relational query languages,
which of the following statements is true?
(a) Relational algebra is more powerful than relational calculus
(b) Relational algebra has the same power as relational calculus.
(c) Relational algebra has the same power as safe relational calculus.
(d) None of the above

1.21 In 2s complement addition, overflow
(a) is flagged whenever there is carry from sign bit addition
(b) cannot occur when a positive value is added to a negative value
(c) is flagged when the carries from sign bit and previous bit match
(d) None of the above

1.22 Which of the following scheduling algorithms is non-preemptive?
(a) Round Robin (b) First-In First-Out
(c) Multilevel Queue Scheduling
(d) Multilevel Queue Scheduling with Feedback

1.23 The optimal page replacement algorithm will select the page that
(a) Has not been used for the longest time in the past.
(b) Will not be used for the longest time in the future.
(c) Has been used least number of times.
(d) Has been used most number of times.

1.24 In the absolute addressing mode
(a) the operand is inside the instruction
(b) the address of the operand is inside the instruction
(c) the register containing the address of the operand is specified inside the
instruction
(d) the location of the operand is implicit

1.25 Maximum number of edges in a n-node undirected graph without self loops is
(a) n
2
(b)
( ) 1
2
n n
(c) n - 1 (d)
( ) ( ) 1
2
n n +

2. This question consists of TWENTY-FIVE sub-questions (2.1 - 2.25) of TWO marks
each. For each of these sub-questions, four possible alternatives, A, B, C and D
are provided. Choose the most appropriate alternative and darken its bubble on
the Objective Response Sheet (ORS) against the corresponding sub-question
number using a soft HB pencil. Do not darken more than one bubble for any
sub-question. Do not use the ORS for any rough work. You may use the answer
book (last few pages) for any rough work.
GATE CS - 2002 GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con
Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum
2.1 Consider the following logic circuit whose inputs are functions f
1
, f
2
, f
3
and output
is f.







Given that

( ) ( )
( ) ( )
( ) ( )
1
2
, , 0,1,3,5 ,
, , 6,7 , and
, , 1, 4,5 ,
f x y z
f x y z
f x y z
=
=
=


f
3
is
(a) ( ) 1, 4,5

(b) ( ) 6,7


(c) ( ) 0,1,3,5

(d) None of the above



2.2 Consider the following multiplexor where 10, 11, 12, 13 are four data input lines
selected by two address line combinations A1A0 =00,01,10,11 respectively and f
is the output of the multiplexor. EN is the Enable input.








The function f(x,y,z) implemented by the above circuit is
(a) xyz (b) xy+z
(c) x+y (d) None of the above

2.3 Let f(A,B) = . A B + Simplified expression for function ( ) ( )
, , f f x y y z + is
(a) x z +
(b) xyz
(c) xy z +
(d) None of the above
f(x,y,z)
f1(x,y,z)
f2(x,y,z)
f3(x,y,z)=?
10
11
12
13
A1
A0
EN
f(x,y,z)=?
4 TO 1
multiplexor
OUTPUT
GATE CS - 2002 GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con
Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum
2.4 What are the states of the Auxillary Carry (AC) and Carry Flag (CY) after
executing the following 8085 program?
MVI H, 5DH
MIV L, 6BH
MOV A, H
ADD L
(a) AC = 0 and CY =0 (b) AC = 1 and CY =1
(c) AC = 1 and CY =0 (d) AC = 0 and CY =1

2.5 The finite state machine described by the following state diagram with A as
starting state, where an arc label is
x
y
and x stands for 1-bit input and y stands
for 2-bit output





(a) Outputs the sum of the present and the previous bits of the input.
(b) Outputs 01 whenever the input sequence contains 11
(c) Outputs 00 whenever the input sequence contains 10
(d) None of the above

2.6 The performance of a pipelined processor suffers if
(a) the pipeline stages have different delays
(b) consecutive instructions are dependent on each other
(c) the pipeline stages share hardware resources
(d) All of the above

2.7 Horizontal microprogramming
(a) does not require use of signal decoders
(b) results in larger sized microinstructions than vertical microprogramming
(c) uses one bit for each control signal
(d) all of the above

2.8 Consider the following declaration of a two-dimensional array in C:
char a[100][100];
Assuming that the main memory is byte-addressable and that the array is stored
starting from memory address 0, the address of a [40][50] is
(a) 4040 (b) 4050 (c) 5040 (d) 5050
0/01
0/00
1/01 1/10
0/01
1/10
A B C
GATE CS - 2002 GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con
Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum
2.9 The number of leaf nodes in a rooted tree of n nodes, with each node having 0 or
3 children is:
(a)
2
n
(b)
( ) 1
3
n
(c)
( ) 1
2
n
(d)
( ) 2 1
3
n +


2.10 Consider the following algorithm for searching for a given number x in an
unsorted array A[l..n] having n distinct values:
1. Choose an i uniformly at random from l..nl
2. If A[i]=x then Stop else Goto 1;
Assuming that x is present A, what is the expected number of comparisons made
by the algorithm before it terminates?
(a) n (b) n - 1 (c) 2n (d)
2
n


2.11 The running time of the following algorithm
Procedure A(n)
If n<=2 return(1) else return (A( n ());
Is best described by
(a) O(n) (b) O(log n) (c) O(log log n) (d) O(1)

2.12 A weight-balanced tree is a binary tree in which for each node, the number of
nodes in the let sub tree is at least half and at most twice the number of nodes in
the right sub tree. The maximum possible height (number of nodes on the path
from the root to the furthest leaf) of such a tree on n nodes is best described by
which of the following?
(a) log
2
n (b)
4
3
log n (c) log
3
n (d)
3
2
log n

2.13 The smallest finite automaton which accepts the language
{ }
length of x is divisible by 3 x has
(a) 2 states (b) 3 states (c) 4 states (d) 5 states

2.14 Which of the following is true?
(a) The complement of a recursive language is recursive.
(b) The complement of a recursively enumerable language is recursively
enumerable.
(c) The complement of a recursive language is either recursive or recursively
enumerable.
(d) The complement of a context-free language is context-free

GATE CS - 2002 GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con
Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum
2.15 The Newton-Raphson iteration
( )
1
3
2 2
n
n
n
X
X
X
+
| |
= +
|
\ .
can be used to solve the
equation
(a)
2
3 X = (b)
3
3 X = (c)
2
2 X = (d)
3
2 X =

2.16 Four fair coins are tossed simultaneously. The probability that at least one head
and one tail turn up is
(a)
1
16
(b)
1
8
(c)
7
8
(d)
15
16


2.17 The binary relation S = (empty set) on set A = {1,2,3} is
(a) Neither reflexive nor symmetric (b) Symmetric and reflexive
(c) Transitive and reflexive (d) Transitive and symmetric

2.18 The C language is:
(a) A context free language (b) A context sensitive language
(c) A regular language
(d) Parsable fully only by a Turing machine

2.19 To evaluate an expression without any embedded function calls
(a) One stack is enough
(b) Two stacks are needed
(c) As many stacks as the height of the expression tree are needed
(d) A Turning machine is needed in the general case

2.20 Dynamic linking can cause security concerns because
(a) Security is dynamic
(b) The path for searching dynamic libraries is not known till runtime
(c) Linking is insecure
(d) Cryptographic procedures are not available for dynamic linking

2.21 Which combination of the following features will suffice to characterize an OS as a
multi-programmed OS? (A) More than one program may be loaded into main
memory at the same time for execution. (B) If a program waits for certain events
such as I/O, another program is immediately scheduled for execution. (C) If the
execution of a program terminates, another program is immediately scheduled
for execution.
(a) A (b) A and B (c) A and C (d) A, B and C


GATE CS - 2002 GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con
Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum

2.22 In the index allocation scheme of blocks to a file, the maximum possible size of
the file depends on
(a) the size of the blocks, and the size of the address of the blocks.
(b) the number of blocks used for the index, and the size of the blocks.
(c) the size of the blocks, the number of blocks used for the index, and the size
of the address of the blocks.
(d) None of the above

2.23 A B
+
- tree index is to be built on the Name attribute of the relation STUDENT.
Assume that all student names are of length 8 bytes, disk blocks are of size 512
bytes, and index pointers are of size 4 bytes. Given this scenario, what would be
the best choice of the degree (i.e. the number of pointers per node) of the B
+
-
tree?
(a) 16 (b) 42 (c) 43 (d) 44

2.24 Relation R is decomposed using a set of functional dependencies, F, and relation
S is decomposed using another set of functional dependencies, G. One
decomposition is definitely BCNF, the other is definitely. 3NF, but it is not known
which is which. To make a guaranteed identification, which one of the following
tests should be used on the decompositions? (Assume that the closures of F and
G are available).
(a) Dependency-preservation (b) Lossless-join
(c) BCNF definition (d) 3NF definition

2.25 From the following instance of a relation schema R(A,B,C), we can conclude that:







(a) A functionally determines B and B functionally determines C
(b) A functionally determines B and B does not functionally determines C
(c) B does not functionally determines C
(d) A does not functionally determines B and B does not functionally determines
C



A B C
1 1 1
1 1 0
2 3 2
2 3 2
GATE CS - 2002 GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con
Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum
SECTION B
This section consists of TWENTY questions of FIVE marks each. Any FIFTEEN out of
these questions have to be answered on the Answer Book provided.

3. Let A be a set of n(>0) elements. Let N
r
be the number of binary relations on A
and let N
f
be the number of functions from A to A.
(a) Give the expression for N
r
in terms of n.
(b) Give the expression for N
f
in terms of n.
(c) Which is larger for all possible n, N
r
or N
f
?

4. (a) S =
{ }
1,2 , 2,1 is binary relation on set A = {1,2,3}. Is it irreflexive? Add
the minimum number of ordered pairs to S to make it an equivalence
relation. Give the modified S.
(b) Let S = {a,b} and let (S) be the powerset of S. Consider the binary
relation ` (set inclusion) on (S). Draw the Hasse diagram corresponding
to the lattice ((S),)

5. (a) Obtain the eigen values of the matrix


1 2 34 49
0 2 43 94
0 0 2 104
0 0 0 1
A
(
(
(
=
(

(
(



(b) Determine whether each of the following is a tautology, a contradiction, or
neither (" is disjunction, " is conjunction, " is implication, " in
negation, and " is biconditional (if and only if).
(i) ( ) A A A
(ii) ( ) A B B
(iii) A (( ) A B

6. Draw all binary trees having exactly three nodes labeled A, B and C on which
Preorder traversal gives the sequence C,B,A.

7. (a) Express the function ( ) , , f x y z xy yz = + with only one complement operation
and one or more AND/OR operations. Draw the logic circuit implementing the
expression obtained, using a single NOT gate and one or more AND/OR
gates.
GATE CS - 2002 GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con
Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum
(b) Transform the following logic circuit (without expressing its switching
function) into an equivalent logic circuit that employs only 6 NAND gates
each with 2-inputs.







8. Consider the following circuit. A = a
2
a
1
a
0
and B = b
2
b
1
b
0
are three bit binary
numbers input to the circuit. The output is Z = z
3
z
2
z
1
z
0
. R0, R1 and R2 are
registers with loading clock shown. The registers are loaded with their input data
with the falling edge of a clock pulse (signal CLOCK shown) and appears as
shown. The bits of input number A, B and the full adders are as shown in the
circuit. Assume Clock period is greater than the settling time of all circuits.

















(a) For 8 clocks pulses on the CLOCK terminal and the inputs A, B as shown,
obtain the output Z (sequence of 4-bit values of Z). Assume initial contents
of R0, R1 and R2 as all zeros.

A= 110 011 111 101 000 000 000 000
B= 101 101 011 110 000 000 000 000
Clock No 1 2 3 4 5 6 7 8
(b) What does the circuit implement?

A
EA
CLOCK
b2 a2
a1 b1
b0 a0
b2 a2
a1 b1
b2 a2
EA
EA
Z=z3
z2
z1
z0
REG R0
(6 - bit)
REG R1
(6 - bit)
REG R2
(5 - bit)
B
0
GATE CS - 2002 GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con
Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum
9. Consider the following 32-bit floating-point representation scheme as shown in
the formal below. A value is specified by 3 fields, a one bit sign field (with 0 for
positive and 1 for negative values), a 24 bit fraction field (with the binary point
being at the left end of the fraction bits), and a 7 bit exponent field (in excess-64
signed integer representation, with 16 being the base of exponentiation). The
sign bit is the most significant bit.





(a) It is required to represent the decimal value -7.5 as a normalized floating
point number in the given format. Derive the values of the various fields.
Express your final answer in the hexadecimal.
(b) What is the largest values that can be represented using this format?
Express your answer as the nearest power of 10.

10. In a C program, an array is declared as float A[2048]. Each array element is 4
Bytes in size, and the starting address of the array is 000000000. This program
is run on a computer that has a direct mapped data cache of size 8 Kbytes, with
block (line) size of 16 Bytes.
(a) Which elements of the array conflict with element A[0] in the data cache?
Justify your answer briefly.
(b) If the program accesses the elements of this array one by one in reverse
order i.e., starting with the last element and ending with the first element,
how many data cache misses would occur? Justify your answer briefly.
Assume that the data cache is initially empty and that no other data or
instruction accesses are to be considered.

11. The following recursive function in C is a solution to the Towers of Hanoi problem.
Void move (int n, char A, char B, char C)
{
if (..............) {
move (..............);
printf("Move disk %d from pole %c to pole %c\n, n, A,C);
move (..............);
Fill in the dotted parts of the solution.






1 24 ?
sign fraction exponent
GATE CS - 2002 GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con
Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum
12. Fill in the blanks in the following template of an algorithm to compute all pairs
shortest path lengths in a directed graph G with n*n adjacency matrix A.
A[i,j]equals if there is an edge in G from i to j, and 0 otherwise. Your aim in filling
in the blanks is to ensure that the algorithm is correct.
INITIALIZATION: For i = 1 . n
{For j = 1 . n
{ if A[i,j]=0 then P[i,j] = _______ else P[i,j] =____;}
ALGORITHM: For i = 1 .n
{ For j = 1 .n
{For k = 1 .n
{P[__,___]=min{_______,_______};}
}
}
(a) Copy the complete line containing the blanks in the Initialization step and fill
in the blanks.
(b) Copy the complete line containing the blanks in the Algorithm step and fill in
the blanks.
(c) Fill in the blank: The running time of the Algorithm is O(____).

13. (a) In how many ways can a given positive integer n 2 be expressed as the
sum of 2 positive integers (which are not necessarily distinct). For example,
for n = 3, the number of ways is 2, i.e., 1+2, 2+1. Give only the answer
without any explanation.
(b) In how many ways can a given positive integer n 3 be expressed as the
sum of 3 positive integers (which are not necessarily distinct). For example,
for n = 4, the number of ways is 3, i.e., 1+2+1, 2+1+1. Give only the
answer without any explanation.
(c) In how many ways can a given positive integer n k be expressed as the
sum of k positive integers (which are not necessarily distinct)? Give only the
answer without explanation.

14. The aim of the following question is to prove that the language {M | M is the
code of a Turing Machine which, irrespective of the input, halts and outputs a 1},
is undecidable. This is to be done by reducing form the language
{ }
, halts on , M x M x which is known to be undecidable. In parts (a) and (b)
describe the 2 main steps in the construction of M. in part (c) describe the key
propery which relates the behaviour of M on its input w to the behaviour of M on
x.
(a) On input w, what is the first step that M must make?
(b) On input w, based on the outcome of the first step, what is the second step
that M must make?
(c) What key property relates the behaviour of M on w to the behaviour of M on
x?
GATE CS - 2002 GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con
Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum
15. A university placement center maintains a relational database of companies that
interview students on campus and make job offers to those successful in the
interview. The schema of the database is given below:
COMPANY (cname, clocation) STUDENT (scrollno, sname, sdegree)
INTERVIEW (cname, srollno, idate) OFFER (cname,srollno, osalary)
The COMPANY relation gives the name and location of the company. The
STUDENT relation gives the students roll number, name and the degree program
for which the student is registered in the university. The INTERVIEW relation
gives the date on which a students is interviewed by a company. The OFFER
relation gives the salary offered to a student who is successful in a companys
interview. The key for each relation is indicated by the underlined attributes.
(a) Write relational algebra expressions (using only the operator ,,,, )
for the following queries:
(i) List the rollnumbers and names of those students who attended at least one
interview but did not receive any job offer.
(ii) List the rollnumbers and names of students who went for interviews and
received job offers from every company with which they interviewed.
(b) Write an SQL query to list, for each degree program in which more than five
students were offered jobs, the name of the degree and the average offered
salary of students in this degree program.

16. For relation R = (L, M, N , O, P), the following dependencies hold:
M O NO P P L and L MN
R is decomposed into R
1
=(L, M, N , P) and R
2
= (M, O).
(a) Is the above decomposition a lossless-join decomposition? Explain.
(b) Is the above decomposition dependency-preserving? If not, list all the
dependencies that are not preserved.
(c) What is the highest normal form satisfied by the above decomposition?

17. (a) The following table refers to search times for a key in B-trees and B
+
-trees.




A successful search means that the key exists in the database and
unsuccessful means that it is not present in the database. Each of the entries
X
1
, X
2
, X
3
and X
4
can have a value of either Constant or Variable. Constant
means that the search time is the same, independent of the specific key
value, where Variable means that it is dependent on the specific key value
chosen for the search.
Give the correct values for the entries X
1
, X
2
, X
3
and X
4
(for example X
1
=
Constant, X
2
= Constant, X
3
= Constant, X
4
= Constant).

B-tree B
+
-tree
Successful Search Unsuccessful search Successful Search Unsuccessful search
X
1
X
2
X
3
X
4
GATE CS - 2002 GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con
Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum
(b) Relation R(A,B) has the following view defined on it:
CREATE VIEW V AS
(SELECT R1.A,R2.B
FROM R AS R1, R AS R2
WHERE R1.B=R2.A)

(i) The current contents of relation R are shown below. What are the contents of
the view V?









(ii) The tuples (2,11) and (11,6) are now inserted into R. What are the additional
tupels that are inserted in V?

18. (a) Draw the process state transition diagram of an OS in which (i) each process
is in one of the five states: created, ready, running, blocked (i.e. sleep or
wait), or terminated, and (ii) only non-preemptive scheduling is used by the
OS. Label the transitions appropriately.
(b) The functionality of atomic TEST-AND-SET assembly language instruction is
given by the following C function.
int TEST-AND-SET (int *x)
{
int y;
A1:y=*x;
A2:*x=1;
A3:return y;
}
(i) Complete the following C functions for implementing code for entering and
leaving critical sections based on the above TEST-AND-SET instruction.
int mutex=0;
void enter-cs()
{
while (.............);
}
A B
1 2
2 3
2 4
4 5
6 7
6 8
9 10
GATE CS - 2002 GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con
Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum
void leave-cs()
{
...............;
}
(ii) Is the above solution to the critical section problem deadlock free and
starvation-free?
(iii) For the above solution, show by an example that mutual exclusion is not
ensured if TEST-AND-SET instruction is not atomic.

19. A computer system uses 32-bit virtual address, and 32-bit physical address. The
physical memory is byte addressable, and the page size is 4 kbytes. It is decided
to use two level page tables to translate from virtual address to physical address.
Equal number of bits should be used for indexing first level and second level page
table, and the size of each page table entry is 4 bytes.
(a) Give a diagram showing how a virtual address would be translated to a
physical address.
(b) What is the number of page table entries that can be contained in each
page?
(c) How many bits are available for storing protection and other information in
each page table entry?

20. The following solution to the single producer single consumer problem uses
semaphores for synchronization.
#define BUFFSIZE 100
buffer buf[BUFFSIZE];
int first=last=0;
semaphore b_full=0;
semaphore b_empty=BUFFSIZE;

void producer()
{
while (1) {
produce an item;
p1: .........;
put the item into buff (first);
first=(first+1)%BUFFSIZE;
p2: .........;
}
}
void consumer()
{


GATE CS - 2002 GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con
Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum
while (1) {
c1:..........
take the item from buf[last];
last=(last+1)%BUFFSIZE;
c2: ..........;
consume the item;
}
}

(a) Complete the dotted part of the above solution.
(b) Using another semaphore variable, insert one line statement each
immediately after p1, immediately before p2, immediately after c1, and
immediately before c2 so that the program works correctly for multiple
procedures and consumers.

21. We require a four state automaton to recognize the regular expression
( ) * . a b abb
(a) Give an NFA for this purpose.
(b) Give a DFA for this purpose.

22. (a) Construct all the parse trees corresponding to i + j * k for the grammar
E E+E
E E*E
E id

(b) In this grammar, what is the precedence of the two operators * and +?
(c) If only one parse tree is desired for any string in the same language, what
changes are to be made so that the resulting LALR(1) grammar is non-
ambiguous?



Address: 17A, 30
th
Cross, Tilak Nagar, Jayanagar 4
th
`T Block, Bangalore - 560 041.
Ph: 080 - 51310203.
Centres:
Mumbai
GATE FORUM
110, Shopper's Point
1st Floor , S. V. Road
Opp. Andheri Railway Station.
Andheri (W) Mumbai.
Tel: (022) 2623 7471 / 72
Kolkata
GATE FORUM
4A, ELGIN Road
Next to Bhavanipur College
Kolkata-700020
Tel: (033) 30947075, 30947160
Jaipur
GATE FORUM
C-16 , Greater Kailash Colony,
Behind New Vidhan Sabha, Lal
Kothi, Jaipur, Rajasthan.
PIN : 302001,Tel:(0141) 5103580

Trivandrum
GATE FORUM
TC 14/ 1679 , Behind Sanskrit
College, Palayam, Trivandrum
Kerala PIN : 695034.
Tel : (471) 2322914,
Nagpur
GATE FORUM
3rd Floor, Samarth Chambers
W.H.C Road, Opp. Chauhan
Traders,
Nagpur - 440 010,
Maharashtra
Dhanbad
GATE FORUM
Flat NO: 3 B, HEM Tower,
Luby Circular Road,
Dhanbad 826001
Tel: (0326) 3108848

Durgapur
GATE FORUM
2nd floor, Nachan Road
Opposite Bank of India,
Benachity.
Durgapur - 713213
Pune
GATE FORUM
5, Kalpana Building
opp. Hotel Surya
Off Ghole Road
Pune - 411004
Tel : (020) 25538396 / 25510078
Guwahati
GATE FORUM
Maniram Dewan Road
Opposite to Regalia Marriage Hall,
Chandmari
Guwahati 781003
Tel. 91 98640 75835


Hubli / Dharwad
GATE FORUM
Plot no. 101, Shri
Venktesh Krupa,
Shiv Basav Nagar,
BELGAUM Pin 591 010
(Land mark: Naganoor swami
Kalyan Mantap
Hyderabad
GATE FORUM
Suite Number 515,Model
House
Hyderabad - 82
Ph: +91-40-5583 3454
+91-40-5583 3242





Duration: 3 Hours Maximum Marks:150


Read the following instructions carefully:

1. This question paper contains 90 objective questions. Q.1 to Q.30 carry One mark each and
Q.31 to Q.90 carry Two marks each.
2. Answer all the questions.
3. Questions must be answered on special machine gradable Objective Response Sheet
(ORS) by darkening the appropriate bubble (marked A, B, C, D) against the question
number on the left hand side of the ORS, using HB pencil. Each question has only one
correct answer. In case you wish to change an answer, erase the old answer completely
using a good soft eraser.
4. There will be NEGATIVE marking. In Q.1 to Q.30, 0.25 mark will be deducted for each
wrong answer and in Q.31 to Q.90, 0.5 mark will be deducted for each wrong answer.
More than one answer marked against a question will be deemed as an incorrect response
and will be negatively marked.
5. Write your registration number, name and name of the Centre at the specified locations on
the right half of the ORS.
6. Using HB pencil, darken the appropriate bubble under each digit of your registration
number and the letters corresponding to your paper code.
7. No charts or tables are provided in the examination hall.
8. Use the blank pages given at the end of the question paper for rough work.
9. Choose the closest numerical answer among the choice given.
10. Please check all pages and report, if there is any discrepancy.




Website: www.gateforum.com
Email: support@gateforum.com
Enter your Roll Number Here:
Enter your Test ID here:
GATE CS - 2004 GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con

Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum
Q: 1 - Q.30 carry one mark each

1. The goal of structured programming is to
(a) have well indented programs
(b) be able to infer the flow of control from the compiled code
(c) be able to infer the flow of control form the program text
(d) avoid the use of GOTO statements

2. Consider the following C function
vaid swap (int a, int b)
{ int temp;
temp = a ;
a = b ;
b = temp ;
}
In order to exchange the values of two variables x and y.
(a) call swap (x, y)
(b) call swap (&x, &y)
(c) swap (x,y) cannot be used as it does not return any value
(d) swap (x,y) cannot be used as the parameters are passed by value

3. A single array A[1..MAXSIZE] is used to implement two stacks. The two stacks
grow from opposite ends of the array. Variables top1 and top 2 (top1< top 2)
point to the location of the topmost element in each of the stacks. If the space is
to be used efficiently, the condition for "stack full is
(a) (top1 = MAXSIZE/2) and (top2 = MAXSIZE/2+1)
(b) top1 + top2 = MAXSIZE
(c) (top1 = MAXSIZE/2) or (top2 = MAXSIZE)
(d) top1 = top2 -1

4. The following numbers are inserted into an empty binary search tree in the given
order: 10, 1, 3, 5, 15, 12, 16. What is the height of the binary search tree (the
height is the maximum distance of a leaf node from the root)?
(a) 2 (b) 3 (c) 4 (d) 6

5. The best data structure to check whether an arithmetic expression has balanced
parentheses is a
(a) queue (b) stack (c) tree (d) list


GATE CS - 2004 GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con

Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum

6. Level order traversal of a rooted tree can be done by starting from the root and
performing
(a) preorder traversal (b) in-order traversal
(c) depth first search (d) breadth first search

7. Given the following input (4322, 1334, 1471, 9679, 1989, 6171, 6173, 4199) and
the hash function x mod 10, which of the following statements are true?
i) 9679, 1989, 4199 hash to the same value
ii) 1471, 6171 has to the same value
iii) All elements hash to the same value
iv) Each element hashes to a different value
(a) i only (b) ii only (c) i and ii only (d) iii or iv

8. Which of the following grammar rules violate the requirements of an operator
grammar? P, Q, R are nonterminals, and r,s,t are terminals.
(i) P Q R (ii) P Q s R
(iii) P (iv) P Q t R r
(a) (i) only (b) (i) and (iii) only
(c) (ii) and (iii) only (d) (iii) and (iv) only

9. Consider a program P that consists of two source modules M
1
and M
2
contained in
two different files. If M
1
contains a reference to a function defined in M
2
the
reference will be resolved at
(a) Edit time (b) Compile time
(c) Link time (d) Load time

10. Consider the grammar rule E E
1
- E
2
for arithmetic expressions. The code
generated is targeted to a CPU having a single user register. The subtraction
operation requires the first operand to be in the register. If E
1
and E
2
do not have
nay-common sub-expression, in order to get the shortest possible code
(a) E
1
should be evaluated first
(b) E
2
should be evaluated first
(c) Evaluation of E
1
and E
2
should necessarily be interleaved
(d) Order to evaluation of E
1
and E
2
is of no consequence

11. Consider the following statements with respect to user-level threads and kernel-
supported threads
(i) context switch is faster with kernel-supported threads
(ii) for user-level threads, a system call can block the entire process
(iii) Kernel supported threads can be scheduled independently
(iv) User level threads are transparent to the kernel
GATE CS - 2004 GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con

Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum
Which of the above statements are true?
(a) (ii), (iii) and (iv) only (b) (ii) and (iii) only
(c) (i) and (iii) only (d) (i) and (ii) only

12. Consider an operating system capable of loading and executing a single
sequential user process at a time. The disk head scheduling algorithm used is
First Come First Served (FCFS). If FCFS is replaced by Shortest Seek Time First
(SSTF), claimed by the vendor to give 50% better benchmark results, what is the
expected improvement in the I/O performance of user programs?
(a) 50% (b) 40% (c) 25% (d) 0%

13. Let R
1
(A,B,((D) and R
2
(D,E) be two relation schema, where the primary keys
are shown underlined, and let C be a foreign key in R
1
referring to R
2
. Suppose
there is no violation of the above referential integrity constraint in the
corresponding relation instances r
1
and r
2
. Which one of the following relational
algebra expressions would necessarily produce an empty relation?
(a) ( ) ( )
2 1 D C
r r (b) ( ) ( )
1 2 C D
r r
(c)
D
(r
1 C D
r
2
)

(d)
C
(r
1 C = D
r
2
)



14. Consider the following relation schema pertaining to a students database:
Students (rollno, name, address)
Enroll(rollno,courseno, coursename)
Where the primary keys are shown underlined. The number of tuples in the
student and Enroll tables are 120 and 8 respectively. What are the maximum and
minimum number of tuples that can be present in (Student * Enroll), where `*
denotes natural join?
(a) 8,8 (b) 120,8 (c) 960,8

(d) 960,120



15. Choose the best matching between Group 1 and Group 2

Group -1 Group - 2
P. Data link layer
1. Ensures reliable transport of data over a physical point-to-point
link
Q. Network layer 2. Encodes/decodes data for physical transimission
R. Transport layer 3. Allows end-to-end communication between two processes
4. Routes data from one network node to the next

(a) P - 1, Q - 4, R - 3 (b) P - 2, Q - 4, R - 1
(c) P - 2, Q - 3, R - 1

(d) P - 1, Q - 3, R - 2

GATE CS - 2004 GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con

Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum
16. Which of the following is NOT true with respect to a transparent bridge and a
router?
(a) Both bridge and router selectively forward data packets
(b) A bridge uses IP addresses while a router uses MAC addresses
(c) A bridge builds up its routing table by inspecting incoming packets


(d) A router can connect between a LAN and a WAN
17. A Boolean function x y xy x y + + is equivalent to
(a) x y + (b) x y + (c) x y +

(d) x y +

18. In an SR latch made by cross-coupling two NAND gates, if both S and R inputs
are set to 0, then it will result in
(a) Q = 0, 1 Q = (b) 1, 0 Q Q = =
(c) 1, 1 Q Q = =

(d) Indeterminate states

19. If 73
x
(in base-x number system) is equal to 54
y
(in base y-number system), the
possible values of x and y are
(a) 8, 16 (b) 10, 12 (c) 9, 13

(d) 8, 11

20. Which of the following addressing modes are suitable for program relocation at
run time?
(i) Absolute addressing (ii) Based addressing
(iii) Relative addressing (iv) Indirect addressing
(a) (i) and (iv) (b) (i) and (ii)
(c) (ii) and (iii)

(d) (i), (ii) and (iv)

21. The minimum number of page frames that must be allocated to a running
process in a virtual memory environment is determined by
(a) the instruction set architecture
(b) page size
(c) physical memory size


(d) number of processes in memory

22. How many 8-bit characters can be transmitted per second over a 9600 baud
serial communication link using asynchronous mode of transmission with one
start bit, eight data bits, two stop bits, and one parity bit?
(a) 600 (b) 800 (c) 876

(d) 1200

23. Identify the correct translation into logical notation of the following assertion.
Some boys in the class are taller than all the girls
Note: taller (x,y) is true if x is taller than y.
GATE CS - 2004 GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con

Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum
(a) (x) (boy(x) (y) (girl(y) taller(x,y)))
(b) (x) (boy(x) (y) (girl(y) taller(x,y)))
(c) (x) (boy(x) (y) (girl(y) taller(x,y)))
(d) (x) (boy(x) (y) (girl(y) taller(x,y)))

24. Consider the binary relation:
S = ( ) { } { }
, 1 and , 0,1,2 x y y x x y = +
The reflexive transitive closure of S is
(a) ( ) { } { }
, and , 0,1,2 x y y x x y > (b) ( ) { } { }
, and , 0,1,2 x y y x x y
(c) ( ) { } { }
, and , 0,1,2 x y y x x y < (d) ( ) { } { }
, and , 0,1,2 x y y x x y

25. If a fair coin is tossed four times. What is the probability that two heads and two
tails will result?
(a)
3
8
(b)
1
2
(c)
5
8
(d)
3
4


26. The number of different n n symmetric matrices with each element being either
0 or 1 is : (Note: power (2,x) is same as 2
x
)
(a) power (2,n) (b) power(2,n
2
)
(c) power (2, (n
2
+n/2) (d) power (2, (n
2
- n)/2)

27. Let A,B,C,D be n n matrices, each with non-zero determinant. If ABCD=I, then
B
-1
is
(a) D
-1
C
-1
A
-1
(b) CDA
(c) ADC (d) Does not necessarily exist

28. What is the result of evaluating the following two expressions using three-digit
floating point arithmetic with rounding?

( )
( )
113. 111. 7.51
113. 111. 7.51
+ +
+ +

(a) 9.51 and 10.0 respectively (b) 10.0 and 9.51 respectively
(c) 9.51 and 9.51 respectively (d) 10.0 and 10.0 respectively

29. The tightest lower bound on the number of comparisons, in the worst case, for
comparison-based sorting is of the order of
(a) n (b) n
2
(c) nlogn (d) nlog
2
n


GATE CS - 2004 GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con

Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum
30. The problem 3-SAT and 2-SAT are
(a) both in P (b) both NP complete
(c) NP-complete and in P respectively
(d) undecidable and NP-complete respectively

Q: 31 - 90 carry two marks each
31. Consider the following C function:
int f(int n)
{ static int i = 1 ;
if (n >=5) return n;
n = n+I;
i++;
return f(n);
}
The value returned by f(1) is
(a) 5 (b) 6 (c) 7 (d) 8

32. Consider the following program fragment for reversing the digits in a given
integer to obtain a new integer. Let n = d
1
d
2
.d
m
.
int n, rev;
rev = 0;
while (n > 0) {
rev = rev *10+n % 10;
n = n / 10 ;
}
The loop invariant condition at the end of the i
th
iteration is:
(a)
1 2 1 1
... and rev= ...
m i m m m i
n d d d d d d
+
=
(b)
1 1 m 2 1
... d or rev= ...
m i m m i
n d d d d d
+
=
(c) n rev
(d)
1 2 2 1
... or ...
m m
n d d d rev d d d = =

33. Consider the following C program segment:
char p [20]
char * s = "string;
int length = strlen (s);
for (i = 0 ; i < length; i++)
p[i] = s[length - I];
print f("%,p);
GATE CS - 2004 GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con

Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum
The output of the program is
(a) gnirts (b) string
(c) gnirt (d) no output is printed

34. It is desired to design an object-oriented employee record system for a company.
Each employee has a name, unique id and salary. Employees belong to different
categories and their salary is determined by their category. The functions get
Name, getld and compute salary are required. Given the class hierarchy below,
possible locations for these functions are:
(i) getld is implemented in the superclass
(ii) getld is implemented in the subclass
(iii) getName is an abstract function in the superclass
(iv) getName is implemented in the superclass
(v) getName is implemented in the subclass
(vi) getSalary is an abstract function in the superclass
(vii) getSalary is implemented in the superclass
(viii) getSalary is implemented in the subclass









Choose the best design
(a) (i), (iv), (vi), (viii) (b) (i), (iv), (vii)
(c) (i), (iii), (v), (vi), (viii) (d) (ii), (v), (viii)

35. Consider the label sequences obtained by the following pairs of traversals on a
labeled binary tree. Which of these pairs identify a tree uniquely?
i) preorder and postorder ii) inorder and postorder
iii) preorder and inorder iv) level order and postorder
(a) (i) only (b) (ii), (iii) (c) (iii) only (d) (iv) only





Employee
Manager Engineer Secretary
GATE CS - 2004 GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con

Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum
36. A circularly linked list is used to represent a Queue. A single variable p is used to
access the Queue. To which node should p point such that both the operations
enQueue and deQueue can be performed in constant time?








(a) rear node (b) front node
(c) not possible with a single pointer (d) node next to front

37. The elements 32, 15, 20, 30, 12, 25, 16, are inserted one by one in the iven
order into a maxHeap. The resultant maxHeap is
(a) (b)










(c) (d)











Front Rear
P ?
32
30 25
16 20 12
15
32
25 30
16 20 15
12
32
30 25
20 16 12
15
32
25 30
20 16 15
12
GATE CS - 2004 GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con

Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum
38. Assume that the operators +, -, , are left associative and ^ is right associative.
The order of precedence (from highest to lowest) is ^, , +, -. The postfix
expression corresponding to the infix expression a + bc-d^e^f is
(a) abc+def^^- (b) abc+de^f^-
(c) ab+cd-e^f^ (d) - + abc^^def

39. Two matrices M
1
and M
2
are to be stored in arrays A and B respectively. Each
array can be stored either in row-major or column-major order in contiguous
memory locations. The time complexity of an algorithm to compute M
1
M
2
will
be
(a) best if A is in row-major, and B is in column major order
(b) best if both are in row-major order
(c) best if both are in column-major order
(d) independent of the storage scheme

40. Suppose each set is represented as a linked list with elements in arbitray order.
Which of the operations among union, intersection, membership, cardinality will
be the slowest?
(a) union only (b) intersection, membership
(c) membership, cardinality (d) union, intersection

41. Consider the following C program
main ( )
{ int x, y, m, n;
scanf ("%d %d, &x, &y);
/ *Assume x > 0 and y > 0 */
m = x; n = y;
while (m! = n)
{ if (m > n)
m = m - n;
else
n = n - m;
}
printf("%d,n);
}
The program computes
(a) x + y using repeated subtraction
(b) x mod y using repeated subtraction
(c) the greatest common divisor of x and y
(d) the least common multiple of x and y

GATE CS - 2004 GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con

Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum
42. What does the following algorithm approximate? (Assume m > 1, > 0).
X = m;
Y = 1;
While (x - y > )
{ x = (x + y) / 2;
y = m/x;
}
print (x);

(a) log m (b)
2
m (c)
1
2
m (d)
1
3
m

43. Consider the following C program segment
struct CellNode{
struct CellNode *leftChild;
int element;
struct CellNode *rightChild;
};
int Dosomething (struct CellNode *ptr)
{
int value = 0;
if (ptr ! = NULL)
{ if (ptr - > leftChild ! = NULL)
value = 1 + DoSomething (ptr - > leftChild);
if (ptr - > rightChild ! = NULL)
value = max(value,1 + DoSomething (ptr - > rightChild));
}
return (value);
}
The value returned by the function DoSomething when a pointer to the root of a
non-empty tree is passed as argument is
(a) The number of leaf nodes in the tree
(b) The number of nodes in the tree
(c) The number of internal nodes in the tree
(d) The height of the tree




GATE CS - 2004 GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con

Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum
44. Suppose we run Dijkstras single source shortest-path algorithm on the following
edge-weighted directed graph with vertex P as the source.









In what order do the nodes get included into the set of vertices for which the
shortest path distances are finalized?
(a) P,Q,R,S,T,U (b) P,Q,R,U,S,T (c) P,Q,R,U,T,S (d) P,Q,T,R,U,S

45. Consider the grammar with the following translation rules and E as the start
symbol.
E E
1
# T {E.value = E
1
.value * T.value}
| T {E.value = T.value}
T T
1
& F {T.value = T
1
.value * F.value}
| F {T.value = F.value}
F num {F.value = num.value}
Compute E.value for the root of the parse tree for the expression:2 # 3 & 5 # 6
& 4.
(a) 200 (b) 180 (c) 160 (d) 40

46. Consider the following set of processes, with the arrival times and the CPU-burst
times given in milliseconds.

Process Arrival Time Burst Time
P1 0 5
P2 1 3
P3 2 3
P4 4 1

What is the average turnaround time for these processes with the preemptive
shortest remaining processing time first (SRPT) algorithm?
(a) 5.50 (b) 5.75 (c) 6.00 (d) 6.25


P
Q R
S
T U
1
1
1
2
2
2 4
3
6
7
GATE CS - 2004 GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con

Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum
47. Consider a system with a two-level paging scheme in which a regular memory
access takes 150 nanoseconds, and servicing a page fault takes 8 milliseconds.
An average instruction takes 100 nanoseconds of CPU time, and two memory
accesses. The TLB hit ratio is 90%, and the page fault rate is one in every 10,000
instructions. What is the effective average instruction execution time?
(a) 645 nanoseconds (b) 1050 nanoseconds
(c) 1215 nanoseconds (d) 1230 nanoseconds

48. Consider two processes P
1
and P
2
accessing the shared variables X and Y
protected by two binary semaphores S
x
and S
y
respectively, both initialized to 1.
P and V denote the usual semaphore operators, where P decrements the
semaphore value, and V increments the semaphore value. The pseudo-code of P
1

and P
2
is as follows:
P
1
: P
2
:
While true do {
L
1: .........
L
2: .........
X = X + 1;
Y = Y - 1;
V(S
x
);
V(S
y);
}
While true do {
L
3: .........
L
4: .........
Y = Y + 1;
X = Y - 1;
V(S
y
);
V(S
x
); }
In order to avoid deadlock, the correct operators at L
1
, L
2
, L
3
and L
4
are
respectively.
(a) ( ) ( ) ( ) ( ) , ; ,
Y X X Y
P S P S P S P S (b) ( ) ( ) ( ) ( ) , ; ,
X Y Y X
P S P S P S P S
(c) ( ) ( ) ( ) ( ) , ; ,
X X Y Y
P S P S P S P S (d) ( ) ( ) ( ) ( ) , ; ,
X Y X Y
P S P S P S P S

49. A unix-style I-node has 10 direct pointers and one single, one double and one
triple indirect pointers. Disk block size is 1 Kbyte, disk block address is 32 bits,
and 48-bit integers are used. What is the maximum possible file size?
(a)
24
2 bytes (b)
32
2 bytes (c)
34
2 bytes (d)
48
2 bytes

50. The relation scheme Student Performance (name, courseNo, rollNo, grade) has
the following functional dependencies:
name, courseNo, grade
rollNo, courseNo grade
name rollNo
rollNo name
The highest normal form of this relation scheme is
(a) 2 NF (b) 3 NF (c) BCNF (d) 4 NF

GATE CS - 2004 GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con

Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum
51. Consider the relation Student (name, sex, marks), where the primary key is
shown underlined, pertaining to students in a class that has at least one boy and
one girl. What does the following relational algebra expression produce)
(Note: is the rename operator).

( ) ( )
(
( )
)
^
^
, ,

sex female
x male
marks m
name sex female name n x m
r Student Student Student
=
=
_
=
1

H H



( )
(a) names of girl students with the highest marks
(b) names of girl students with more marks than some boy student
(c) names of girl students with marks not less than some boy student
(d) names of girl students with more marks than all the boy students

52. The order of an internal node in a B+ tree index is the maximum number of
children it can have. Suppose that a child pointer takes 6 bytes, the search field
value takes 14 bytes, and the block size is 512 bytes. What is the order of the
internal node?
(a) 24 (b) 25 (c) 26 (d) 27

53. The employee information in a company is stored in the relation
Employee (name, sex, salary, deptName)
Consider the following SQL query
Select deptName
From Employee
Where sex = `M
Group by deptName
Having avg(salary) >
(select avg (salary) from Employee)
It returns the names of the department in which
(a) the average salary is more than the average salary in the company
(b) the average salary of male employees is more than the average salary of all
male employees in the company
(c) the average salary of male employees is more than the average salary of
employees in the same department.
(d) the average salary of male employees is more than the average salary in the
company




GATE CS - 2004 GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con

Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum
54. A and B are the only two stations on an Ethernet. Each has a steady queue of
frames to send. Both A and B attempt to transmit a frame, collide, and A wins
the first backoff race. At the end of this successful transmission by A, both A and
B attempt to transmit and collide. The probability that A wins the second backoff
race is
(a) 0.5 (b) 0.625 (c) 0.75 (d) 1.0

55. The routing table of a router is shown below:








On which interface will the router forward packets addressed to destinations
128.75.43.16 and 192.12.17.10 respectively?
(a) Eth1 and Eth2 (b) Eth0 and Eth2 (c) Eth0 and Eth3 (d) Eth1 and Eth3

The following information pertains to Q.56 and 57:
Consider three IP networks A, B and C. Host H
A
in networks A sends messages each
containing 180 bytes of application data to a host H
C
in network C. The TCP layer
prefixes a 20 byte header to the message. This passes through an intermediate network
B. the maximum packet size, including 20 byte IP header, in each network is:
A : 1000 bytes
B : 100 bytes
C : 1000 bytes
The network A and B are connected through a 1 Mbps link, while B and C are connected
by a 512 Kbps link (bps = bits per second).





56. Assuming that the packets are correctly delivered, how many bytes, including
headers, are delivered to the IP layer at the destination for one application
message, in the best case? Consider only data packets.
(a) 200 (b) 220 (c) 240 (d) 260

Destination Subnet Mask Interface
128.75.43.0 255.255.255.0 Eth0
128.75.43.0 255.255.255.128 Eth1
192.12.17.5 255.255.255.255 Eth3
Default Eth2
Network C
Network A Network B
1 Mbps 512 Mbps
GATE CS - 2004 GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con

Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum
57. What is the rate at which application data is transferred to host H
C
? Ignore
errors, acknowledgements, and other overheads.
(a) 325.5 Kbps (b) 354.5 Kbps (c) 409.6 Kbps (d) 512.0 Kbps

58. A circuit outputs a digit in the form of 4 bits. 0 is represented by 0000, 1 by
0001, ., 9 by 1001. A combinational circuit is to be designed which takes these 4
bits as input and outputs 1 if the digit 5, and 0 otherwise. If only AND, OR and
NOT gates may be used, what is the minimum number of gates required?
(a) 2 (b) 3 (c) 4 (d) 5

59. Which are the essential prime implicants of the following Boolean function?
( ) , , f a b c a c ac b c =
(a) and a c ac (b) and a c b c (c) a c only (d) and ac bc

60. Consider a multiplexer with X and Y as data inputs and Z as control input. Z = 0
selects input X, and Z = 1 selects input Y. What are the connections required to
realize the 2-variable Boolean function f = T + R, without using any additional
hardware?
(a) R to X, 1 to Y, T to Z (b) T to X, R to Y, T to Z
(c) T to X, R to Y, 0 to Z (d) R to X, 0 to Y, T to Z

61. Consider the partial implementation of a 2-bit counter using T flip-flops following
the sequence 0-2-3-1-0, as shown below.









To complete the circuit, the input X should be
(a)
2
Q

(b)
2 1
Q Q (c) ( )
1 2
Q Q

(d)
1 2
Q Q

62. A 4-bit carry look ahead adder, which adds two 4-bit numbers, is designed using
AND, OR, NOT, NAND, NOR gates only. Assuming that all the inputs are available
in both complemented and uncomplemented forms and the delay of each gate is
one time unit, what is the overall propagation delay of the adder? Assume that
the carry network has been implemented using two-level AND-OR logic.
(a) 4 time units (b) 6 time units (c) 10 time units (d) 12 time units
T2
Q2
MSB
LSB
T1
Q1
CLK
X
GATE CS - 2004 GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con

Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum
The following information pertains to Q.63 and 64:

Consider the following program segment for a hypothetical CPU having three user
registers R1, R2 and R3.


Instruction Operation Instruction Size (in words)
MOV R1,5000 ;R1 Memory[5000] 2
MOV R2(R1) ;R2 Memory[(R1)] 1
ADD R2, R3 ;R2 R2 + R3 1
MOV 6000, R2 ; Memory[6000] R2 2
HALT ;Machine halts 1

63. Consider that the memory is byte addressable with size 32 bits, and the program
has been loaded starting form memory location 1000 (decimal). If an interrupt
occurs while the CPU has been halted after executing the HALT instruction, the
return address (in decimal) saved in the stack will be
(a) 1007 (b) 1020 (c) 1024 (d) 1028

64. Let the clock cycles required fro various operations be as follows:
Register to/from memory transfer : 3 clock cyles
ADD with both operands in register : 1 clock cyle
Instruction fetch and decode : 2 clock cycles per word
The total number of clock cycles required to execute the program is
(a) 29 (b) 24 (c) 23 (d) 20

65. Consider a small two-way set-associative cache memory, consisting of four
blocks. For choosing the block to be replaced, use the least recently used (LRU)
scheme. The number of cache misses for the following sequence of block
addresses is 8, 12, 0, 12,8
(a) 2 (b) 3 (c) 4 (d) 5

66. Let A = 1111 1010 and B = 0000 1010 be two 8-bit 2s complement numbers.
Their product in 2s complement is
(a) 1100 0100 (b) 1001 1100 (c) 1010 0101 (d) 1101 0101





GATE CS - 2004 GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con

Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum
67. The microinstructions stored in the control memory of a processor have a width
of 26 bits. Each microinstruction is divided into three fields: a micro-operation
field of 13 bits, a next address field (X), and a MUX select field (Y). there are 8
status bits in the inputs of the MUX.















How many bits are there in the X and Y fields, and what is the size of the control
memory in number of words?
(a) 10, 3, 1024 (b) 8, 5, 256 (c) 5, 8, 2048 (d) 10, 3, 512

68. A hard disk with a transfer rate of 10 Mbytes/second is constantly transferring
data to memory using DMA. The processor runs at 600 MHz, and takes 300 and
900 clock cycles to initiate and complete DMA transfer respectively. If the size of
the transfer is 20 Kbytes, what is the percentage of processor time consumed for
the transfer operation?
(a) 5.0% (b) 1.0% (c) 0.5% (d) 0.1%

69. A 4-stage pipeline has the stage delays as 150, 120, 160 and 140 nanoseconds
respectively. Registers that are used between the stages have a delay of 5
nanoseconds each. Assuming constant clocking rate, the total time taken to
process 1000 data items on this pipeline will be
(a) 120.4 microseconds (b) 160.5 microseconds
(c) 165.5 microseconds (d) 590.0 microseconds

70. The following prepositional statement is ( ) ( ) ( ) ( ) P Q R P Q R .
(a) satisfiable but not valid (b) valid
(c) a contradiction (d) None of the above

Control Address
Register
Micro Operations
Control
Memory
Status Bits
Increment
Y
X
8
13
Load
MUX
GATE CS - 2004 GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con

Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum
71. How many solutions does the following system of linear equations have?

5 1
2
3 3
x y
x y
x y
=
=
=

(a) infinitely many (b) two distinct solutions
(c) unique (d) none

72. The following is the incomplete operation table of a 4-element group.







The last row of the table is
(a) c a e b (b) c b a e (c) c b e ac e a b

73. The inclusion of which of the following sets into
1,2 , 1,2,3 , 1,3,5 , 1,2, 4 , 1,2,3, 4,5 S =
is necessary and sufficient to make S a complete lattice under the partial order
defined by set containment?
(a) 1 (b) 1 , 2,3
(c) 1 , 1,3 (d) 1 , 1,3 , 1,2,3, 4 , 1,2,3,5

74. An examination paper has 150 multiple choice questions of one mark each, with
each question having four choices. Each incorrect answer fetches -0.25 marks.
Suppose 1000 students choose all their answers randomly with uniform
probability. The sum total of the expected marks obtained by all these students is
(a) 0 (b) 2550 (c) 7525 (d) 9375
75. Mala has a colouring book in which each English letter is drawn two times. She
wants to paint each of these 52 prints with one of k colours, such that he colour
pairs used to colour any two lwtters are different. Both prints of a letter can also
be coloured with the same colour. What is the minimum value of k that satisfies
this requirement?
(a) 9 (b) 8 (c) 7 (d) 6



* e a b c
e e a b c
a a b c e
b
c
GATE CS - 2004 GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con

Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum
76. In an MN matrix such that all non-zero entries are covered in a rows and b
columns. Then the maximum number of non-zero entries, such that no two are
on the same row or column, is
(a) a +b (b) max(a,b) (c) min(M-a,N-b) (d) min(a,b)

77. The minimum number of colours required to colour the following graph, such that
no two adjacent vertices are assigned the same colour, is
(a) 2
(b) 3
(c) 4
(d) 5


78. Two n bit binary strings, S
1
and S
2
are chosen randomly with uniform probability.
The probability that the Hamming distance between these strings (the number of
bit positions where the two strings differ) is equal to d is
(a) / 2
n n
d
C (b) / 2
n d
d
C (c) / 2
n
d (d) 1/ 2
d


79. How many graph on n labeled vertices exist which have at least
( )
2
3
2
n n
edges.
(a)
( )
( )
2 / 2
2 3 / 2
n n
n n
C

(b)
( )
( )
2 3 / 2
2
0
n n
n n
k
k
C

=
_
(c)
( ) 2 / 2 n n
n
C

(d)
( ) 2 / 2
0
n
n n
k
k
C

=
_


80. A point is randomly selected with uniform probability in the X-Y plane within the
rectangle with corners at (0,0), (1,0), (1,2) and (0,2). If p is the length of the
position vector of the point, the expected value of
2
p is
(a)
2
3
(b) 1 (c)
4
3
(d)
5
3


81. Let ( ) ( )
1 1 2 2
, and , G V E G V E = = be connected graphs on the same vertex set V
with more than two vertices. If ( )
1 2 1 2
, G G V E E = is not a connected graph,
then the graph ( )
1 2 1 2
, G G V E E ' = '
(a) cannot have a cut vertex
(b) must have a cycle
(c) must have a cut-edge (bridge)
(d) has chromatic number strictly greater than those of
1 2
and G G



GATE CS - 2004 GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con

Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum
82. Let A[1,.,n] be an array storing a bit (1 or 0) at each location, and f(m) is a
function whose time complexity is (m). Consider the following program fragment
written in a C like language:
counter = 0;
for (i =1; i < = n; i++)
{if (a[i] == 1) counter++;
else {f (counter); counter = 0;)
}
The complexity of this program fragment is
(a)
( )
2
n (b) (nlogn) and O
( )
2
n
(c) (n) (d) o(n)

83. The time complexity of the following C function is (assume n > 0)
int recursive (int n) {
if (n == 1)
return (1);
else
return (recursive (n-1) + recursive (n-1);
}
(a) O(n) (b) O(nlog n) (c) O
( )
2
n (d) O
( )
2
n


84. The recurrence equation

( )
( ) ( )
1 1
2 1 , 2
T
T n T n n n
=
= _

evaluates to
(a)
1
2 2
n
n

(b) 2
n
n (c)
1
2 2 2
n
n

(d) 2
n
n

85. A program takes as input a balanced binary search tree with n leaf nodes and
computes the value of a function g(x) for each node x. If the cost of computing
g(x) is min(number of leaf-nodes in left-subtree of x, number of leaf-nodes in
right-subtree of x) then the worst-case time complexity of the program is
(a) ( ) n (b) ( ) log n n (c)
( )
2
n (d)
( )
2
log n n






GATE CS - 2004 GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con

Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum
86. The following finite state machine accepts all those binary strings in which the
number of 1s and 0s are respectively










(a) divisible by 3 and 2 (b) odd and even
(c) even and odd (d) divisible by 2 and 3

87. The language

, 1
m n m n
a b c m n

_ is
(a) regular (b) context-free but not regular
(c) context sensitive but not context free (d) type-0 but not context sensitive

88. Consider the following grammar G:

S bS aA b
A bA aB
B bB aS a


Let ( ) ( ) and
a b
N N denote the number of as and bs in a string respectively.
The language ( ) , L G a b

_ generated by G is
(a) ( ) ( )
3
a b
N N (b) ( ) ( )
3
b a
N N
(c) ( )
3 , 0,1,2,...
a
N k k = (d) ( )
3 , 0,1,2,...
b
N k k =

89. L
1
is a recursively enumerable language over . An algorithm A effectively
enumerates its words as
1
,
2
,
3
, . define another language L
2
over # '
_
as

1
# : , .
i j j
L i j < Here # is a new symbol. Consider the following assertions.
S
1
: L
1
is recursive implies L
2
is recursive
S
2
: L
2
is recursive implies L
1
is recursive
Which of the following statements is true?
(a) Both S
1
and S
2
are true
(b) S
1
is true but S
2
is not necessarily true
1 1
1
1
1 1
0 0
0 0 0 0
GATE CS - 2004 GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con

Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum
(c) S
2
is true but S
1
is not necessarily true
(d) Neither is necessarily true

90. Choose the best matching between the programming styles in Group1 and their
characteristics in Group 2.

Group 1 Group 2
P. Functional 1. Command-based, procedural
Q. Logic 2. Imperative, abstract data types
R. Object-oriented 3. Side-effect free, declarative, expression evaluation
S. Imperative 4. Declarative, clausal representation, theorem proving

(a) P - 2 Q - 3 R - 4 S - 1 (b) P - 4 Q - 3 R - 2 S - 1
(c) P - 3 Q - 4 R - 1 S - 2 (d) P - 3 Q - 4 R - 2 S - 1

Address: 17A, 30
th
Cross, Tilak Nagar, Jayanagar 4
th
`T Block, Bangalore - 560 041.
Ph: 080 - 51310203.
Centres:
Mumbai
GATE FORUM
110, Shopper's Point
1st Floor , S. V. Road
Opp. Andheri Railway Station.
Andheri (W) Mumbai.
Tel: (022) 2623 7471 / 72
Kolkata
GATE FORUM
4A, ELGIN Road
Next to Bhavanipur College
Kolkata-700020
Tel: (033) 30947075, 30947160
Jaipur
GATE FORUM
C-16 , Greater Kailash Colony,
Behind New Vidhan Sabha, Lal
Kothi, Jaipur, Rajasthan.
PIN : 302001,Tel:(0141) 5103580

Trivandrum
GATE FORUM
TC 14/ 1679 , Behind Sanskrit
College, Palayam, Trivandrum
Kerala PIN : 695034.
Tel : (471) 2322914,
Nagpur
GATE FORUM
3rd Floor, Samarth Chambers
W.H.C Road, Opp. Chauhan
Traders,
Nagpur - 440 010,
Maharashtra
Dhanbad
GATE FORUM
Flat NO: 3 B, HEM Tower,
Luby Circular Road,
Dhanbad 826001
Tel: (0326) 3108848

Durgapur
GATE FORUM
2nd floor, Nachan Road
Opposite Bank of India,
Benachity.
Durgapur - 713213
Pune
GATE FORUM
5, Kalpana Building
opp. Hotel Surya
Off Ghole Road
Pune - 411004
Tel : (020) 25538396 / 25510078
Guwahati
GATE FORUM
Maniram Dewan Road
Opposite to Regalia Marriage Hall,
Chandmari
Guwahati 781003
Tel. 91 98640 75835


Hubli / Dharwad
GATE FORUM
Plot no. 101, Shri
Venktesh Krupa,
Shiv Basav Nagar,
BELGAUM Pin 591 010
(Land mark: Naganoor swami
Kalyan Mantap
Hyderabad
GATE FORUM
Suite Number 515,Model
House
Hyderabad - 82
Ph: +91-40-5583 3454
+91-40-5583 3242





Duration: 3 Hours Maximum Marks:150


Read the following instructions carefully:

1. This question paper contains all objective questions. Q.1 to Q.30 carry One mark each and
Q.31 to Q.80 carry Two marks each. Q.81 to Q.85 each contains part "a and "b. In these
questions, parts "a as well as "b carry Two marks each.
2. Answer all the questions.
3. Questions must be answered on special machine gradable Objective Response Sheet
(ORS) by darkening the appropriate bubble (marked A, B, C, D) against the question
number on the left hand side of the ORS, using HB pencil. Each question has only one
correct answer. In case you wish to change an answer, erase the old answer completely
using a good soft eraser.
4. There will be NEGATIVE marking. In Q.1 to Q.30, 0.25 mark will be deducted for each
wrong answer and in Q.31 to Q.80, 0.5 mark will be deducted for each wrong answer. In
Q.81 to Q.85, for the part "a, 0.5 marks will be deducted for a wrong answer. Marks for
correct answers to part "b of Q.81 to Q.85 will be given only if the answer to the
corresponding part "a is correct. However there is no negative marking for part "b of
Q.81 to Q.85. More than one answer bubbled against a question will be deemed as an
incorrect response.
5. Write your registration number, name and name of the Centre at the specified locations on
the right half of the ORS.
6. Using HB pencil, darken the appropriate bubble under each digit of your registration
number and the letters corresponding to your paper code.
7. Calculator is allowed in the examination hall.
8. Charts, graph sheets or tables are not allowed.
9. Use the blank pages given at the end of the question paper for rough work.
10. Please check all pages and report, if there is any discrepancy.




Website: www.gateforum.com
Email: support@gateforum.com
Enter your Roll Number Here:
Enter your Test ID here:
GATE CS - 200S GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con
Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum
Q.1 - Q.30 carry one mark each.

1. What does the following C-statement declare?
int ( * f) (int * ) ;
(a) A function that takes an integer pointer as argument and returns an integer
(b) A function that takes an integer as argument and returns an integer pointer
(c) A pointer to a function that takes an integer pointer as argument and returns
an integer.
(d) A function that takes an integer pointer as argument and returns a function
pointer

2. An Abstract Data Type (ADT) is:
(a) same as an abstract class
(b) a data type that cannot be instantiated
(c) a data type type for which only the operations defined on it can be used, but
none else
(d) all of the above

3. A common property of logic programming languages and functional languages is:
(a) both are procedural languages (b) both are based on -calculus
(c) both are declarative (d) both use Horn-clauses

4. Which one of the following are essential features of an object-oriented
programming language?
(i) Abstraction and encapsulatoin
(ii) Strictly-typedness
(iii) Type-safe property coupled with sub-type rule
(iv) Polymorphism in the presence of inheritance
(a) (i) and (ii) only (b) (i) and (iv) only
(c) (i), (ii) and (iv) only (d) (i), (iii) and (iv) only

5. A program P reads in 500 integers in the range [0,100] representing the scores
of 500 students. It then prints the frequency of each score above 50. what would
be the best way for P to store the frequencies?

(a) An array of 50 numbers (b) An array of 100 numbers
(c) An array of 500 numbers
(d) A dynamically allocated array of 550 numbers

GATE CS - 200S GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con
Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum
6. An undirected graph G has n nodes. Its adjacency matrix is given by an n n
square matr4ix whose (i) diagonal elements are 0s and (ii) non-diagonal
elements are 1s. which one of the following is TRUE?
(a) Graph G has no minimum spanning tree (MST)
(b) Graph G has a unique MST of cost n-1
(c) Graph G has multiple distinct MSTs, each of cost n-1
(d) Graph G has multiple spanning trees of different costs

7. The time complexity of computing the transitive closure of a binary relation on a
set of n elements is known to be:
(a) O(n) (b) O(n log n) (c) O
3
2
n
| |
|
|
\ .
(d) O
( )
3
n
8. Let A, B and C be non-empty sets and let
( ) ( ) ( ) and X A B C Y A C B C = =
Which one of the following is TRUE?
(a) X = Y (b) X Y (c) Y X (d) None of these

9. The following is the Hasse diagram of the poset { } , , , , , a b c d e (








The poset is:
(a) not a lattice
(b) a lattice but not a distributive lattice
(c) a distributive lattice but not a Boolean algebra
(d) a Boolean algebra

10. Let G be a simple connected planar graph with 13 vetices and 19 edges. Then,
the number of faces in the planar embedding of the graph is:
(a) 6 (b) 8 (c) 9 (d) 13

11. Let G be a simple graph with 20 vertices and 100 edges. The size of the
minimum vertex cover of G is 8. then, the size of the maximum independent set
of G is:
(a) 12 (b) 8 (c) Less than 8 (d) More than 12

a
b
e
d c
GATE CS - 200S GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con
Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum
12. Let f(x) be the continuous probability density function of a random variable X. the
probability that a < X b, is:
(a) ( ) f b a (b) ( ) ( ) f b f a (c) ( )
b
a
f x dx
}
(d) ( )
b
a
xf x dx
}

13. The set {1, 2, 4, 7, 8, 11, 13, 14} is a group under multiplication modulo 15. the
inverses of 4 and 7 are respectively:
(a) 3 and 13 (b) 2 and 11 (c) 4 and 13 (d) 8 and 14

14. The grammar A AA | ( A) | is not suitable for predictive-parsing because the
grammar is:
(a) ambiguous (b) left-recursive
(c) right-recursive (d) an operator-grammar

15. Consider the following circuit.







Which one of the following is TRUE?
(a) f is independent of X (b) f is independent of Y
(c) f is independent of Z (d) None of X, Y, Z is redundant

16. The range of integers that can be repreented by an n bit 2s complement number
system is:
(a)
( )
1 1
2 to 2 1
n n
(b)
( ) ( )
1 1
2 1 to 2 1
n n

(c)
1 1
2 to 2
n n
(d)
( ) ( )
1 1
2 1 to 2 1
n n
+
17. The hexadecimal representation of
8
657 is:
(a) 1AF (b) D78 (c) D71 (d) 32F

18. The switching expression corresponding to f(A,B,C,D)= ( ) 1, 4,5, 9,11,12

is:
(a) BC D A C D AB D + + (b) ABC ACD B C D + +
(c) ACD A BC AC D + + (d) A BD ACD BCD + +

X
Z
Y
f
GATE CS - 200S GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con
Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum
19. Which one of the following is true for a CPU having a single interrupt request line
and a single interrupt grant line?
(a) Neither vectored interrupt nor multiple interrupting devices are possible
(b) Vectored interrupts are not possible but multiple interrupting devices are
possible.
(c) Vectored interrupts and multiple interrupting devices are both possible
(d) Vectored interrupt is possible but multiple interrupting devices are not
possible

20. Normally user programs are prevented from handling I/O directly by I/O
instructions in them. For CPUs having explicit I/O instructions, such I/O
protection is ensured by having the I/O instructions privileged. In a CPU with
memory mapped I/O, there is no explicit I/O instruction. Which one of the
following is true for a CPU with memory mapped I/O?
(a) I/O protection is ensured by operating system routine(s)
(b) I/O protection is ensured by a hardware trap
(c) I/O protection is ensured during system configuration
(d) I/O protection is not possible

21. What is the swap space in the disk used for?
(a) Saving temporary html pages (b) Saving process data
(c) Storing the super-block (d) Storing device drivers

22. Increasing the RAM of a computer typically improves performance because:
(a) Virtual memory increases (b) Larger RAMs are faster
(c) Fewer page faults occur (d) Fewer segmentation faults occur

23. Packets of the same session may be routed through different paths in:
(a) TCP, but not UDP (b) TCP and UDP
(c) UDP, but not TCP (d) Neither TCP nor UDP

24. The address resolution protocol (ARP) is used for:
(a) Finding the IP address from the DNS
(b) Finding the IP address of the default gateway
(c) Finding the IP address that corresponds to a MAC address
(d) Finding the MAC address that corresponds to an IP address

25. The maximum window size for data transmission using the selective reject
protocol with n-bit frame sequence numbers is:
(a) 2
n
(b)
1
2
n
(c) 2 1
n
(d)
2
2
n

GATE CS - 200S GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con
Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum

26. In a network of LANs connected by bridges, packets are sent from one LAN to
another through intermediate bridges. Since more than one path may exist
between two LANs, packets may have to be routed through multiple bridges. Why
is the spanning tree algorithm used for bridge-routing?
(a) For shortest path routing between LANs
(b) For avoiding loops in the routing paths
(c) For fault tolerance (d) For minimizing collisions

27. An organization has a class B network and wishes to form subnets for 64
departments. The subnet mask would be:
(a) 255.255.0.0 (b) 255.255.64.0
(c) 255.255.128.0 (d) 255.255.252.0

28. Which one of the following is a key factor for preferring B
+
-trees to binary search
trees for indexing database relations?
(a) Database relations have a large number of records
(b) Database relations are sorted on the primary key
(c) B
+
-trees require less memory than binary search trees
(d) Data transfer form disks is in blocks

29. Which one of the following statements about normal forms is FALSE?
(a) BCNF is stricter than 3NF
(b) Lossless, dependency-preserving decomposition into 3NF is always possible
(c) Lossless, dependency-preserving decomposition into BCNF is always possible
(d) Any relation with two attributes is in BCNF

30. Let r be a relation instance with schema R = (A, B, C, D). We define
r
1
= ( ) ( )
, , 2 ,
and .
A B C A D
R r r =
1 2
Let * s r r = where * denotes natural join. Given
that the decomposition of r into r
1
and r
2
is lossy, which one of the following is
TRUE?
(a) s r (b) r s = r (c) r s (d) r * s = s

Q.31 to Q.80 carry two marks each.

31. Consider the following C-program:
void foo (int n, int sum 0) {
int k = 0, j = 0;
if (n==0) return;
k = n % 10; j = n / 10;
sum = sum + k;
GATE CS - 200S GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con
Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum
foo (j, sum);
printf (%d,, k);
}
int main () {
int a = 2048, sum = 0;
foo (a, sum);
printf(%d\n, sum);
}

What does the above program print?
(a) 8, 4, 0, 2, 14 (b) 8, 4, 0, 2, 0 (c) 2, 0, 4, 8, 14 (d) 2, 0, 4, 8, 0

32. Consider the following C-program:
double foo (double); /* Line 1 */

int main () {
double da, db;
// input da
db = foo (da);
}
double foo (double a) {
return a;
}
The above code compiled without any error or warning. If Line 1 is deleted, the
above code will show:
(a) no compile warning or error
(b) some compiler-warnings not leading to unintended results
(c) some compiler-warnings due to type-mismatch eventually leading to
unintended results
(d) compiler errors

33. Postorder traversal of a given binary search tree, T produces the following
sequence of keys
10, 9, 23, 22, 27, 25, 15, 50, 95, 60, 40, 29
which one of the following sequences of keys can be the result of an in-order
traversal of the tree T?
(a) 9, 10, 15, 22, 23, 25, 27, 29, 40, 50, 60, 95
(b) 9, 10, 15, 22, 40, 50, 60, 95, 23, 25, 27, 29
(c) 29, 15, 9, 10, 25, 22, 23, 27, 40, 60, 50, 95
(d) 95, 50, 60, 40, 27, 23, 22, 25, 10, 9, 15, 29

GATE CS - 200S GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con
Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum
34. A Priority-Queue is implemented as a Max-Heap. Initially, it has 5 elemnts. The
level-order traversal of the heap is given below:
10, 8, 5, 3, 2
Two new elements `1 and `7 are inserted in the heap in that order. The level-
order traversal of the heap after the insertion of the elements is:
(a) 10, 8, 7, 5, 3, 2, 1 (b) 10, 8, 7, 2, 3, 1, 5
(c) 10, 8, 7, 1, 2, 3, 5 (d) 10, 8, 7, 3, 2, 1, 5

35. How many distinct binary search trees can be created out of 4 distinct keys?
(a) 5 (b) 14 (c) 24 (d) 42

36. In a complete k-ary tree, every internal node has exactly k children. The number
of leaves in such a tree with n internal nodes is:
(a) nk (b) (n - 1) k + 1 (c) n(k - 1) + 1 (d) n(k - 1)

37. Suppose ( ) ( ) ( ) 2 , 0 1 1
2
n
T n T n T T
| |
= + = =
|
\ .

Which one of the following is FALSE?
(a) ( )
( )
2
T n O n = (b) ( ) ( ) log T n n n =
(c) ( )
( )
2
T n n = (d) ( ) ( ) log T n O n n =

38. Let G(V,E) be an undirected graph with positive edge weights. Dijkstras single
source shortest path algorithm can be implemented using the binary heap data
structure with time complexity:
(a)
( )
2
O V (b)
( )
log O E V V +
(c)
( )
log O V V (d)
( ) ( )
log O E V V +

39. Suppose there are log sorted lists of log n n n ( (
(
elements each. The time
complexity of producing a sorted list of all these elements is: (Hint: Use a heap
data structure)
(a) O(n log log n) (b) (n log n) (c) (n log n) (d)
3
2
n
| |
|
|
\ .


40. Let P, Q and R be tree atomic prepositional assertions. Let X denote ( ) P Q R
and Y denote (P R) (Q R). which one of the following is a tautology?
(a) X Y (b) X Y (c) Y X (d) Y X
GATE CS - 200S GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con
Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum
41. What is the first order predicate calculus statement equivalent to the following?
Every teacher is liked by some student
(a) (x)[teacher(x) (y) [student(y) likes (y,x)]]
(b) (x)[teacher(x) (y) [student(y) likes (y,x)]]
(c) (y) (x)[teacher(x) [student(y) likes (y,x)]]
(d) (x)[teacher(x) (y) [student(y) likes (y,x)]]

42. Let R and S be any two equivalence relations on a non-empty set A. Which one of
the following statements is TRUE?
(a) R S, R S are both equivalence relations.
(b) R S is an equivalence relation.
(c) R S is an equivalence relation.
(d) Neither R S nor R S is an equivalence relation

43. Let f: B C and g: A B be two functions let h = . f g Given that h is an onto
function which one of the following is TRUE?
(a) f and g should both be onto functions
(b) f should be onto but g need to be onto
(c) g should be onto but f need not be onto
(d) both f and g need to be onto

44. What is the minimum number of ordered pairs of non-negative numbers that
should be chosen to ensure that there are two pairs (a,b) and (c,d) in the chosen
set such that
mod 3 mod 5 a c and b d
(a) 4 (b) 6 (c) 16 (d) 24

45. Consider three decision problems
1 2 3
, and . P P P It is known that
1
P is decidable
and
2
P is undecidable. Which one of the following is TRUE?
(a)
3
P is decidable if
1
P is reducible to
3
P
(b)
3
P is undecidable if
3
P is reducible to
2
P
(c)
3
P is undecidable if
2
P is reducible to
3
P
(d)
3
P is decidable if
3
P is reducible to
2
P s complement





GATE CS - 200S GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con
Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum
46. Consider the set H of all 3 3 matrices of the type
0
0 0
a f e
b d
c
(
(
(
(


where a,b,c,d,e and f are real numbers and abc0. under the matrix
multiplication operation, the set H is:
(a) a group
(b) a monoid but not a group
(c) a semi group but not a monoid
(d) neither a group nor a semi group

47. Which one of the following graphs is NOT planar?
















(a) G
1
(b) G
2
(c) G
3
(d) G
4

48. Consider the following system of equations in three real variables
1 2 3
, and : x x x

1 2 3
1 2 3
1 2 3
2 3 1
3 2 5 2
4 3
x x x
x x x
x x x
+ =
+ + =
+ + =

The system of equations has
(a) no solution (b) a unique solution
(c) more than one but a finite number of solutions
(d) an infinite number of solutions
G1: G2:
G3:
G4:
GATE CS - 200S GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con
Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum
b
a
a
a
a
b b
b
a,b
49. What are the eigen values of the following 2 2 matrix?

2 1
4 5
(
(




(a) -1 and 1 (b) 1 and 6 (c) 2 and 5 (d) 4 and -1

50. Let ( )
( )
( )
2
0
1
, where 1.
1
i
i
G x g i x x
x

=
= = <


What is g(i)?
(a) i (b) i+1 (c) 2i (d) 2
i


51. Box P has 2 red balls and 3 blue balls and box Q has 3 balls and 1 blue ball. A
ball is selected as follows: (i) select a box (ii) choose a ball from the selected box
such that each ball in the box is equally likely to be chosen. The probabilities of
selecting boxes P and Q are
1 2
and ,
3 3
respectively. Given that a ball selected in
the above process is a red ball, the probability that it came from the box P is:
(a)
4
19
(b)
5
19
(c)
2
9
(d)
19
30


52. A random bit string of length n is constructed by tossing a fair coin n times and
setting a bit to 0 or 1 depending on outcomes head and tail, respectively. The
probability that two such randomly generated strings are not identical is:
(a)
1
2
n
(b)
1
1
n
(c)
1
! n
(d)
1
1
2
n


53. Consider the machine M:










The language recognized by M is:
(a) { } { }
, * every a in w is followed by exactly two b's w a b

GATE CS - 200S GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con
Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum
(b) { } { }
, * every a in w is followed by at least two b's w a b
(c) { } { }
, * w contains the substring 'abb' w a b
(d) { } { }
, * w does not contain 'aa' as a substring w a b

54. Let
p
and N
f
N denote the classes of languages accepted by non-deterministic
finite automata and non-deterministic push-down automata, respectively. Let
and
f p
D D denote the classes of languages accepted by deterministic finite
automata and deterministic push-down automata respectively. Which one of the
following is TRUE?
(a) and
f f p p
D N D N (b) and
f f p p
D N D N =
(c) and
f f p p
D N D N = = (d) and
f f p p
D N D N =

55. Consider the languages:

{ } { } 1 2
, 0 and , 0
n n m n m m
L a b c n m L a b c n m = > = >
Which one of the following statements is FALSE?
(a) L
1
L
2
is a context-free language (b) L
1
L
2
is a context-free language
(c) L
1
and L
2
are context-free languages
(d) L
1
L
2
is a context sensitive language

56. Let L
1
be a recursive language, and let L
2
be a recursively enumerable but not a
recursive language. Which one of the following is TRUE?
(a)
1
L is recursive and
2
L is recursively enumerable
(b)
1
L is recursive and
2
L is not recursively enumerable
(c)
1
L and
2
L are recursively enumerable
(d)
1
L is recursively enumerable and
2
L is recursive

57. Consider the languages:

{ }
{ }
{ }
{ }
{ }
{ }
1
2
3
0,1 *
# 0,1 * , where # is a special symbol
0,1 *
R
R
L ww w
L w w w
L ww w
=
=
=

Which one of the following is TRUE?
(a) L
1
is a deterministic CFL (b) L
2
is a deterministic CFL
(c) L
3
is a CFL, but not a deterministic CFL (d) L
3
is a deterministic CFL
GATE CS - 200S GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con
Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum
58. Consider the following two problems on undirected graphs:
: Given G(V,E), does G have an independent set of size 4? V
: Given G(V,E), does G have an independent set of size 5?
Which one of the following is TRUE?
(a) is in P and is NP-complete (b) is NP-complete and is in P
(c) Both and are NP-complete (d) Both and are in P

59. Consider the grammar:
E E + n | E n | n
For a sentence n + n n, the handles in the right-sentential form of the reduction
are:
(a) n, E + n and E + n n (b) n, E + n and E + E n
(c) n, n + n and n + n n (d) n, E + n and E n


60. Consider the grammar:
S (S) | a
Let the number of states in SLR (1), LR(1) and LALR(1) parsers for the grammar
be n
1
, n
2
and n
3
respectively. The following relationship holds good:
(a)
1 2 3
n n n < < (b)
1 3 2
n n n = < (c)
1 2 3
n n n = = (d)
1 3 2
n n n

61. Consider line number 3 of the following C-program.
int min ( ) { /* Line 1 */
int I, N; /* Line 2 */
fro (I =0, I<N, I++); /* Line 3 */
}
Identify the compilers response about this line while creating the object-module:
(a) No compilation error (b) Only a lexical error
(c) Only syntactic errors (d) Both lexical and syntactic errors

62. Consider the following circuit involving a positive edge triggered D FF.








A
D
Q X
Q
Y
CLK
GATE CS - 200S GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con
Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum
Consider the following timing diagram. Let A
i
represent the logic level on the line
a in the i-th clock period.








Let A represent the complement of A. the correct output sequence on Y over the
clock periods 1 through 5 is:
(a)
0 1 1 3 4
A A A A A

(b)
0 1 2 3 4
A A A A A


(c)
1 2 2 3 4
A A A A A

(d)
1 2 3 4 5
A A A A A



63. The following diagram represents a finite state machine which takes as input a
binary number from the least significant bit.






Which one of the following is TRUE?
(a) It computes 1s complement of the input number
(b) It computes 2s complement of the input number
(c) It increments the input number
(d) It decrements the input number










0 1 2 3 4 5
X
clk
0/0
Q0
0/1
1/1
Q1
1/0
GATE CS - 200S GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con
Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum
D0
Q0 D1
Q1
Q1' Q0'
clk
64. Consider the following circuit.








The flip-flops are positive edge triggered D FFs. Each state is designated as a
two-bit string Q
0
Q
1
. Let the initial state be 00. the state transition sequence is
(a) 00 11 01 (b) 00 11

(c) 00 10 01 11 (d) 00 11 01 10


65. Consider a three word machine instruction
ADD A[R0], @B
The first operand (destination) "A[R0] uses indexed addressing mode with R0 as
the index register. The second operand (source) "@B uses indirect addressing
mode. A and B are memory addresses residing at the second and the third
words, respectively. The first word of the instruction specifies the opcode, the
index register designation and the source and destination addressing modes.
During execution of ADD instruction, the two operands are added and stored in
the destination (first operand).
The number of memory cycles needed during the execution cycle of the
instruction is:
(a) 3 (b) 4 (c) 5 (d) 6

66. Match each of the high level language statements given on the left hand side with
the most natural addressing mode from those listed on the right hand side.

(1) A[I] = B[J]; (a) Indirect addressing
(2) while (*A++); (b) Indexed addressing
(3) int temp =*x; (c) Auto increment

(a) (1, c), (2,b), (3,a) (b) (1, a), (2,c), (3,b)
(c) (1, b), (2,c), (3,a) (d) (1, a), (2,b), (3,c)

GATE CS - 200S GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con
Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum
67. Consider a direct mapped cache of size 32 KB with block size 32 bytes. The CPU
generates 32 bit addresses. The number of bits needed for cache indexing and
the number of tag bits are respectively.
(a) 10, 17 (b) 10, 22 (c) 15, 17 (d) 5, 17

68. A 5 stage pipelined CPU has the following sequence of stages:
IF - Instruction fetch from instrution memory.
RD - Instruction decode and register read.
EX - Execute: ALU operation for data and address computation.
MA - Data memory access - for write access, the register read at RD state is
used.
WB - Register write back.
Consider the following sequence of instructions:
I
1
: L R0, loc 1; R0 <=M[loc1]
I
2
: A R0, R0 1; R0 <= R0 + R0
I
3
: S R2, R0 1; R2 <= R2 - R0
Let each stage take one clock cycle.
What is the number of clock cycles taken to complete the above sequence of
instructions starting from the fetch of I
1
?
(a) 8 (b) 10 (c) 12 (d) 15

69. A device with data transfer rate 10 KB/sec is connected to a CPU. Data is
transferred byte-wise. Let the interrupt overhead be 4 sec. The byte transfer
time between the device interfaces register and CPU or memory is negligible.
What is the minimum performance gain of operating the device under interrupt
mode over operating it under program-controlled mode?
(a) 15 (b) 25 (c) 35 (d) 45

70. Consider a disk drive with the following specifications:
16 surfaces, 512 tracks/surface, 512 sectors/track, 1 KB/sector, rotation speed
3000 rpm. The disk is operated in cycle stealing mode whereby whenever one 4
byte word is ready it is sent to memory; similarly, for writing, the disk interface
reads a 4 byte word from the memory in each DMA cycle. Memory cycle time is
40 nsec. The maximum percentage of time that the CPU gets blocked during DMA
operation is:
(a) 10 (b) 25 (c) 40 (d) 50

71. Suppose n processes, P
1
, .. P
n
share m identical resource units, which can be
reserved and released one at a time. The maximum resource requirement of
process P
i
is s
i
, where s
i
>0. Which one of the following is a sufficient condition
for ensuring that deadlock does not occur?
(a) ,
i
i s m < (b) ,
i
i s n <
GATE CS - 200S GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con
Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum
(c) ( )
1
n
i
i
s m n
=
< +

(d) ( )
1
*
n
i
i
s m n
=
<



72. Consider the following code fragment:
if (fork () ==0)
{ a = a + 5; printf(%d,%d\n, a, &a); }
else { a = a 5; printf(%d, %d\n, a, &a); }

Let u, be the values printed by the parent process, and x,y be the values
printed by the child process. Which one of the following is TRUE?
(a) u = x + 10 and = y (b) u = x + 10 and is y
(c) u + 10 = x and = y (d) u + 10 = x and y

73. In a packet switching network, packets are routed from source to destination
along a single path having two intermediate nodes. If the message size is 24
bytes and each packet contains a header of 3 bytes, then the optimum packet
size is:
(a) 4 (b) 6 (c) 7 (d) 9

74. Suppose the round trip propagation delay for a 10 Mbps Ethernet having 48-bit
jamming signal is 46.4 s. The minimum frame size is:
(a) 94 (b) 416 (c) 464 (d) 512

75. Let E
1
and E
2
be two entities in an E/R diagram with simple single-valued
attributes. R
1
and R
2
are two relationships between E
1
and E
2
, where R
1
is one-to-
many and R
2
is many-to-many. R
1
and R
2
do not have any attributes of their
own. What is the minimum number of tables required to represent this situation
in the relational model?
(a) 2 (b) 3 (c) 4 (d) 5

76. The following table has two attributes A and C where A is the primary key and C
is the foreign key referencing a with on-delete cascade.

A C
2 4
3 4
4 3
5 2
7 2
9 5
6 4
GATE CS - 200S GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con
Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum
The set of all tuples that must be additionally deleted to preserve referential
integrity when the tuple (2,4) is deleted is:
(a) (3,4) and (6,4) (b) (5,2) and (7,2)
(c) (5,2), (7,2) and (9,5) (d) (3,4), (4,3) and (6,4)

77. The relation book (title,price) contains the titles and prices of different books.
Assuming that no two books have the same price, what does the following SQL
query list?
select title
from book as B
where (select count(*)
from book as T
where T.price>B.price)<5
(a) Titles of the four most expensive books
(b) Title of the fifth most inexpensive book
(c) Title of the fifth most expensive book
(d) Titles of the five most expensive books

78. Consider a relation scheme R = (A,B,C,D,E,H) on which the following functional
dependencies hold: {A B, BC D, E C, D A}. What are the candidate
keys of R?
(a) AE, BE (b) AE, BE, DE
(c) AEH, BEH, BCH (d) AEH, BEH, DEH

Common Data for questions 79 and 80:
Consider the following data path of a CPU.











The ALU, the bus and all the registers in the data path are of identical size. All
operations including incrementation of the PC and the GPRs are to be carried out in the
ALU. Two clock cycles are needed for memory read operation - the first one for loading
MAR
MDR
IR PC
GPRs
S
T
ALU
GATE CS - 200S GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con
Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum
address in the MAR and the next one for loading data from the memory bus into the
MDR.

79. The instruction "add R0, R1 has the register transfer interpretation R0<=
R0+R1. The minimum number of clock cycles needed for execution cycle of this
instruction is:
(a) 2 (b) 3 (c) 4 (d) 5

80. The instruction `call Rn, sub is a two word instruction. Assuming that PC is
incremented during the fetch cycle of the first word of the instruction, its register
transfer interpretation is
Rn<= PC+1;
PC<=M[PC];
The minimum number of CPU clock cycles needed during the execution cycle of
this instruction is:
(a) 2 (b) 3 (c) 4 (d) 5

Linked Answer Questions: Q.81a to Q.85b carry two marks each.
Statement for Linked Answer Questions 81a & 81b:
Consider the following C-function:
double foo (int n) {
int i;
double sum;

if (n==0) return 1.0;
else {
sum = 0.0;
for (i =0; i<n; i++)
sum +=foo(i);
return sum;
} }
81. (A) The space complexity of the above function is:
(a) O(1) (b) O(n) (c) O(n!) (d) O(n
n
)

(B) Suppose we modify the above function foo() and store the values of
foo(i), 0<=I<n, as and when they are computed. With this modification, the
time complexity for function foo() is significantly reduced. The space
complexity of the modified function would be:
(a) O(1) (b) O(n) (c) O(n
2
) (d) O(n!)


GATE CS - 200S GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con
Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum
Statement for Linked Answer Questions 82a & 82b:

Let s and t be two vetices in a undirected graph G=(V,E) having distinct positive edge
weights. Let [X,Y] be a partition of V such that s X and T Y. Consider the edge e
having the minimum weight amongst all those edges that have one vertex in X and one
vertex in Y.
82. (A) The edge e must definitely belong to:
(a) the minimum weighted spanning tree of G
(b) the weighted shortest path from s to t
(c) each path from s to t
(d) the weighted longest path from s to t

(B) Let the weight of an edge e denote the congestion on that edge. The
congestion on a path is defined to be the maximum of the congestions on the
edges of the path. We wish to find the path from s to t having minimum
congestion. Which one of the following paths is always such a path of
minimum congestion?
(a) a path from s to t in the minimum weighted spanning tree
(b) a weighted shortest path from s to t
(c) an Euler walk from s to t
(d) a Hamiltonian path from s to t

Statement for Linked Answer Questions 83a & 83b:
Consider the following expression grammar. The semantic rules for expression
evaluation are stated next to each grammar production.
E number E.val = number.val
| E `+ E E
(1)
.val = E
(2)
.val + E
(3)
.val
| E ` E E
(1)
.val = E
(2)
.val E
(3)
.val

83. (A) The above grammar and the semantic rules are fed to a yacc tool (which is
an LALR(1) parser generator) for parsing and evaluating arithmetic
expressions. Which one of the following is true about the action of yacc for
the given grammar?
(a) It detects recursion and eliminates recursion
(b) It detects reduce-reduce conflict, and resolves
(c) It detects shift-reduce conflict, and resolves the conflict in favor of a shift
over a reduce action.
(d) It detects shift-reduce conflict, and resolves the conflict in favor of a reduce
over a shift action.



GATE CS - 200S GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con
Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum
(B) Assume the conflicts in Part (a) of this question are resolved and an LALR(1)
parser is generated for parsing arithmetic expressions as per the given
grammar. Consider an expression 3 2 + 1. What precedence and
associativity properties does the generated parser realize?
(a) Equal precedence and left associativity; expression is evaluated to 7
(b) Equal precedence and right associativity; expression is evaluated to 9
(c) Precedence of ` is higher than that of `+, and both operators are left
associative; expression is evaluated to 7
(d) Precedence of `+ is higher than that of `, and both operators are left
associative; expression is evaluated to 9

Statement for Linked Answer Questions 84a & 84b:
We are given 9 tasks T
1
, T
2
, .. T
9
. The execution of each task requires one unit of time.
We can execute one task at a time. Each task T
i
has a profit P
i
and a deadline d
i
. Profit P
i

is earned if the task is completed before the end of the
th
i
d unit of time.
Task T
1
T
2
T
3
T
4
T
5
T
6
T
7
T
8
T
9
Profit 15 20 30 18 18 10 23 16 25
Deadline 7 2 5 3 4 5 2 7 3

84. (A) Are all tasks completed in the schedule that gives maximum profit?
(a) All tasks are completed (b) T
1
and T
6
are left out
(c) T
1
and T
8
are left out (d) T
4
and T
6
are left out

(B) What is the maximum profit earned?
(a) 147 (b) 165 (c) 167 (d) 175

Statement for Linked Answer Questions 85a & 85b:

Consider the following floating-point format.






Mantissa is a pure fraction in sign-magnitude form.
85. (A) The decimal number 0.239 2
13
has the following hexadecimal
representation (without normalization and rounding off):
(a) 0D 24 (b) 0D 4D (c) 4D 0D (d) 4D 3D

15 14
8 7 0
Sign bit Excess-64
Exponent
Mantissa
GATE CS - 200S GATE Forum www.gateIorum.com
Join discussion of iIis icsi acr ai Iii.//forun.gaicncnior.con
Join AII IndIa Mock GATE CIassroom Test SerIes - 2006 conducicd ly CATE Forun in ovcr 25 ciiics all ovcr India. Qucsiion
Pacrs including scciion icsis and full icsis arc dcsigncd ly IISc alunni according io iIc laicsi syllalus. Pcrccniilc, All India Fanl,
inicraciion wiiI IISc alunni in our onlinc discussion foruns, and norc. RegIstratIon starts 10
tb
May, 200S. For norc dciails,
visii
www.gcIefcrum.ccm
Ihink G/IE Ihink G/IE Fcrum
(B) The normalized representation for the above format is specified as follows.
The mantissa has an implicit 1 preceding the binary (radix) point. Assume
that only 0s are padded in while shifting a field.
The normalized representation of the above number
( )
13
0.239 2 is:
(a) 0A 20 (b) 11 34 (c) 49 D0 (d) 4A E8

Anda mungkin juga menyukai