Page 1
GATE CS  2003
Q.1 — Q.30 carry one mark each.
1. Consider the following C function.
float f,(float x, int y) {
float p, s; int i;
for (s=1,p=1,i=1; i<y; i++) {
p *= x/i;
s+=p;
}
return s;
}
For large values of y, the return value of the function f best approximates
(A)
y
X (B) e
x
(C) ln(1+x) (D)
x
X
2. Assume the following C variable declaration
int * A[10], B[10][10];
Of the following expressions
I. A[2] II. A[2][3] III. B[1] IV. B[2][3]
which will not give compiletime errors if used as left hand sides of assignment
statements in a C program?
(A) I,II, and IV only (B) II, III, and IV only
(C) II and IV only (D) IV only
3. Let P(E) denote the probability of the event E. Given P(A) = 1, P(B) =
1
2
, the
values of P(AB) and P(BA) respectively are
(A)
1
4
,
1
2
(B)
1
2
,
1
4
(C)
1
2
, 1 (D) 1,
1
2
4. Let A be a sequence of 8 distinct integers sorted in ascending order. How many
distinct pairs of sequences, B and C are there such that (i) each is sorted in
ascending order, (ii) B has 5 and C has 3 elements, and (iii) the result of merging
B and C gives A?
(A) 2 (B) 30 (C) 56 (D) 256
5. n couples are invited to a party with the condition that every husband should be
accompanied by his wife. However, a wife need not be accompanied by her
husband. The number of different gatherings possible at the party is
(A)
2
*2
n
n
n
? ?
? ?
? ?
(B) 3
n
(C)
( ) 2 !
2
n
n
(D)
2n
n
? ?
? ?
? ?
Page 2
GATE CS  2003
Q.1 — Q.30 carry one mark each.
1. Consider the following C function.
float f,(float x, int y) {
float p, s; int i;
for (s=1,p=1,i=1; i<y; i++) {
p *= x/i;
s+=p;
}
return s;
}
For large values of y, the return value of the function f best approximates
(A)
y
X (B) e
x
(C) ln(1+x) (D)
x
X
2. Assume the following C variable declaration
int * A[10], B[10][10];
Of the following expressions
I. A[2] II. A[2][3] III. B[1] IV. B[2][3]
which will not give compiletime errors if used as left hand sides of assignment
statements in a C program?
(A) I,II, and IV only (B) II, III, and IV only
(C) II and IV only (D) IV only
3. Let P(E) denote the probability of the event E. Given P(A) = 1, P(B) =
1
2
, the
values of P(AB) and P(BA) respectively are
(A)
1
4
,
1
2
(B)
1
2
,
1
4
(C)
1
2
, 1 (D) 1,
1
2
4. Let A be a sequence of 8 distinct integers sorted in ascending order. How many
distinct pairs of sequences, B and C are there such that (i) each is sorted in
ascending order, (ii) B has 5 and C has 3 elements, and (iii) the result of merging
B and C gives A?
(A) 2 (B) 30 (C) 56 (D) 256
5. n couples are invited to a party with the condition that every husband should be
accompanied by his wife. However, a wife need not be accompanied by her
husband. The number of different gatherings possible at the party is
(A)
2
*2
n
n
n
? ?
? ?
? ?
(B) 3
n
(C)
( ) 2 !
2
n
n
(D)
2n
n
? ?
? ?
? ?
GATE CS  2003
6. Let T(n) be the number of different binary search trees on n distinct elements.
Then T(n)= ( ) ( )
1
1 ,
n
k
T k T x
=

?
where x is
(A) n – k + 1 (B) n – k (C) n – k – 1 (D) n – k – 2
7. Consider the set S* of all strings over the alphabet S = {0, 1}. S* with the
concatenation operator for strings
(A) does not form a group
(B) forms a noncommutative group
(C) does not have a right identity element
(D) forms a group if the empty string is removed from S*
8. Let G be an arbitrary graph with n nodes and k components. If a vertex is
removed from G, the number of components in the resultant graph must
necessarily lie between
(A) k and n (B) k – 1 and k + 1
(C) k – 1 and n – 1 (D) k + 1 and n – k
9. Assuming all numbers are in 2’s complement representation, which of the
following numbers is divisible by 11111011?
(A) 11100111 (B) 11100100 (C) 11010111 (D) 11011011
10. For a pipelined CPU with a single ALU, consider the following situations
I. The j + 1st instruction uses the result of the jth instruction as an operand
II. The execution of a conditional jump instruction
III. The jth and j + 1st instructions require the ALU at the same time
Which of the above can cause a hazard?
(A) I and II only (B) II and III only (C) III only (D) All the three
11. Consider an array multiplier for multiplying two n bit numbers. If each gate in the
circuit has a unit delay, the total delay of the multiplier is
(A) T (1) (B) T (log n) (C) T (n) (D) T (n
2
)
12. Ram and Shyam have been asked to show that a certain problem ? is NP
complete. Ram shows a polynomial time reduction from the 3SAT problem to ?,
and Shyam shows a polynomial time reduction from ? to 3SAT. Which of the
following can be inferred from these reductions?
(A) ? is NPhard but not NPcomplete (B) ? is in NP, but is not NPcomplete
(C) ? is NPcomplete (D) ? is neither NPhard, nor in NP
Page 3
GATE CS  2003
Q.1 — Q.30 carry one mark each.
1. Consider the following C function.
float f,(float x, int y) {
float p, s; int i;
for (s=1,p=1,i=1; i<y; i++) {
p *= x/i;
s+=p;
}
return s;
}
For large values of y, the return value of the function f best approximates
(A)
y
X (B) e
x
(C) ln(1+x) (D)
x
X
2. Assume the following C variable declaration
int * A[10], B[10][10];
Of the following expressions
I. A[2] II. A[2][3] III. B[1] IV. B[2][3]
which will not give compiletime errors if used as left hand sides of assignment
statements in a C program?
(A) I,II, and IV only (B) II, III, and IV only
(C) II and IV only (D) IV only
3. Let P(E) denote the probability of the event E. Given P(A) = 1, P(B) =
1
2
, the
values of P(AB) and P(BA) respectively are
(A)
1
4
,
1
2
(B)
1
2
,
1
4
(C)
1
2
, 1 (D) 1,
1
2
4. Let A be a sequence of 8 distinct integers sorted in ascending order. How many
distinct pairs of sequences, B and C are there such that (i) each is sorted in
ascending order, (ii) B has 5 and C has 3 elements, and (iii) the result of merging
B and C gives A?
(A) 2 (B) 30 (C) 56 (D) 256
5. n couples are invited to a party with the condition that every husband should be
accompanied by his wife. However, a wife need not be accompanied by her
husband. The number of different gatherings possible at the party is
(A)
2
*2
n
n
n
? ?
? ?
? ?
(B) 3
n
(C)
( ) 2 !
2
n
n
(D)
2n
n
? ?
? ?
? ?
GATE CS  2003
6. Let T(n) be the number of different binary search trees on n distinct elements.
Then T(n)= ( ) ( )
1
1 ,
n
k
T k T x
=

?
where x is
(A) n – k + 1 (B) n – k (C) n – k – 1 (D) n – k – 2
7. Consider the set S* of all strings over the alphabet S = {0, 1}. S* with the
concatenation operator for strings
(A) does not form a group
(B) forms a noncommutative group
(C) does not have a right identity element
(D) forms a group if the empty string is removed from S*
8. Let G be an arbitrary graph with n nodes and k components. If a vertex is
removed from G, the number of components in the resultant graph must
necessarily lie between
(A) k and n (B) k – 1 and k + 1
(C) k – 1 and n – 1 (D) k + 1 and n – k
9. Assuming all numbers are in 2’s complement representation, which of the
following numbers is divisible by 11111011?
(A) 11100111 (B) 11100100 (C) 11010111 (D) 11011011
10. For a pipelined CPU with a single ALU, consider the following situations
I. The j + 1st instruction uses the result of the jth instruction as an operand
II. The execution of a conditional jump instruction
III. The jth and j + 1st instructions require the ALU at the same time
Which of the above can cause a hazard?
(A) I and II only (B) II and III only (C) III only (D) All the three
11. Consider an array multiplier for multiplying two n bit numbers. If each gate in the
circuit has a unit delay, the total delay of the multiplier is
(A) T (1) (B) T (log n) (C) T (n) (D) T (n
2
)
12. Ram and Shyam have been asked to show that a certain problem ? is NP
complete. Ram shows a polynomial time reduction from the 3SAT problem to ?,
and Shyam shows a polynomial time reduction from ? to 3SAT. Which of the
following can be inferred from these reductions?
(A) ? is NPhard but not NPcomplete (B) ? is in NP, but is not NPcomplete
(C) ? is NPcomplete (D) ? is neither NPhard, nor in NP
GATE CS  2003
13. Nobody knows yet if P = NP. Consider the language L defined as follows.
( ) 0 1 * if
otherwise
P NP
L
f
? + =
?
=
?
?
?
Which of the following statements is true?
(A) L is recursive
(B) L is recursively enumerable but not recursive
(C) L is not recursively enumerable
(D) Whether L is recursive or not will be known after we find out if P = NP
14. The regular expression 0*(10*)* denotes the same set as
(A) (1*0)*1* (B) 0+(0+10)*
(C) (0+1)*10(0+1)* (D) None of the above
15. If the strings of a language L can be effectively enumerated in lexicographic (i.e.,
alphabetic) order, which of the following statements is true?
(A) L is necessarily finite
(B) L is regular but not necessarily finite
(C) L is context free but not necessarily regular
(D) L is recursive but not necessarily context free
16. Which of the following suffices to convert an arbitrary CFG to an LL(1) grammar?
(A) Removing left recursion alone
(B) Factoring the grammar alone
(C) Removing left recursion and factoring the grammar
(D) None of the above
17. Assume that the SLR parser for a grammar G has n
1
states and the LALR parser
for G has n
2
states. The relationship between n
1
and n
2
is
(A) n
1
is necessarily less than n
2
(B) n
1
is necessarily equal to n
2
(C) n
1
is necessarily greater than n
2
(D) None of the above
18. In a bottomup evaluation of a syntax directed definition, inherited attributes can
(A) always be evaluated
(B) be evaluated only if the definition is Lattributed
(C) be evaluated only if the definition has synthesized attributes
(D) never be evaluated
Page 4
GATE CS  2003
Q.1 — Q.30 carry one mark each.
1. Consider the following C function.
float f,(float x, int y) {
float p, s; int i;
for (s=1,p=1,i=1; i<y; i++) {
p *= x/i;
s+=p;
}
return s;
}
For large values of y, the return value of the function f best approximates
(A)
y
X (B) e
x
(C) ln(1+x) (D)
x
X
2. Assume the following C variable declaration
int * A[10], B[10][10];
Of the following expressions
I. A[2] II. A[2][3] III. B[1] IV. B[2][3]
which will not give compiletime errors if used as left hand sides of assignment
statements in a C program?
(A) I,II, and IV only (B) II, III, and IV only
(C) II and IV only (D) IV only
3. Let P(E) denote the probability of the event E. Given P(A) = 1, P(B) =
1
2
, the
values of P(AB) and P(BA) respectively are
(A)
1
4
,
1
2
(B)
1
2
,
1
4
(C)
1
2
, 1 (D) 1,
1
2
4. Let A be a sequence of 8 distinct integers sorted in ascending order. How many
distinct pairs of sequences, B and C are there such that (i) each is sorted in
ascending order, (ii) B has 5 and C has 3 elements, and (iii) the result of merging
B and C gives A?
(A) 2 (B) 30 (C) 56 (D) 256
5. n couples are invited to a party with the condition that every husband should be
accompanied by his wife. However, a wife need not be accompanied by her
husband. The number of different gatherings possible at the party is
(A)
2
*2
n
n
n
? ?
? ?
? ?
(B) 3
n
(C)
( ) 2 !
2
n
n
(D)
2n
n
? ?
? ?
? ?
GATE CS  2003
6. Let T(n) be the number of different binary search trees on n distinct elements.
Then T(n)= ( ) ( )
1
1 ,
n
k
T k T x
=

?
where x is
(A) n – k + 1 (B) n – k (C) n – k – 1 (D) n – k – 2
7. Consider the set S* of all strings over the alphabet S = {0, 1}. S* with the
concatenation operator for strings
(A) does not form a group
(B) forms a noncommutative group
(C) does not have a right identity element
(D) forms a group if the empty string is removed from S*
8. Let G be an arbitrary graph with n nodes and k components. If a vertex is
removed from G, the number of components in the resultant graph must
necessarily lie between
(A) k and n (B) k – 1 and k + 1
(C) k – 1 and n – 1 (D) k + 1 and n – k
9. Assuming all numbers are in 2’s complement representation, which of the
following numbers is divisible by 11111011?
(A) 11100111 (B) 11100100 (C) 11010111 (D) 11011011
10. For a pipelined CPU with a single ALU, consider the following situations
I. The j + 1st instruction uses the result of the jth instruction as an operand
II. The execution of a conditional jump instruction
III. The jth and j + 1st instructions require the ALU at the same time
Which of the above can cause a hazard?
(A) I and II only (B) II and III only (C) III only (D) All the three
11. Consider an array multiplier for multiplying two n bit numbers. If each gate in the
circuit has a unit delay, the total delay of the multiplier is
(A) T (1) (B) T (log n) (C) T (n) (D) T (n
2
)
12. Ram and Shyam have been asked to show that a certain problem ? is NP
complete. Ram shows a polynomial time reduction from the 3SAT problem to ?,
and Shyam shows a polynomial time reduction from ? to 3SAT. Which of the
following can be inferred from these reductions?
(A) ? is NPhard but not NPcomplete (B) ? is in NP, but is not NPcomplete
(C) ? is NPcomplete (D) ? is neither NPhard, nor in NP
GATE CS  2003
13. Nobody knows yet if P = NP. Consider the language L defined as follows.
( ) 0 1 * if
otherwise
P NP
L
f
? + =
?
=
?
?
?
Which of the following statements is true?
(A) L is recursive
(B) L is recursively enumerable but not recursive
(C) L is not recursively enumerable
(D) Whether L is recursive or not will be known after we find out if P = NP
14. The regular expression 0*(10*)* denotes the same set as
(A) (1*0)*1* (B) 0+(0+10)*
(C) (0+1)*10(0+1)* (D) None of the above
15. If the strings of a language L can be effectively enumerated in lexicographic (i.e.,
alphabetic) order, which of the following statements is true?
(A) L is necessarily finite
(B) L is regular but not necessarily finite
(C) L is context free but not necessarily regular
(D) L is recursive but not necessarily context free
16. Which of the following suffices to convert an arbitrary CFG to an LL(1) grammar?
(A) Removing left recursion alone
(B) Factoring the grammar alone
(C) Removing left recursion and factoring the grammar
(D) None of the above
17. Assume that the SLR parser for a grammar G has n
1
states and the LALR parser
for G has n
2
states. The relationship between n
1
and n
2
is
(A) n
1
is necessarily less than n
2
(B) n
1
is necessarily equal to n
2
(C) n
1
is necessarily greater than n
2
(D) None of the above
18. In a bottomup evaluation of a syntax directed definition, inherited attributes can
(A) always be evaluated
(B) be evaluated only if the definition is Lattributed
(C) be evaluated only if the definition has synthesized attributes
(D) never be evaluated
GATE CS  2003
19. Suppose the numbers 7, 5, 1, 8, 3, 6, 0, 9, 4, 2 are inserted in that order into an
initially empty binary search tree. The binary search tree uses the usual ordering
on natural numbers. What is the inorder traversal sequence of the resultant
tree?
(A) 7 5 1 0 3 2 4 6 8 9 (B) 0 2 4 3 1 6 5 9 8 7
(C) 0 1 2 3 4 5 6 7 8 9 (D) 9 8 6 4 2 3 0 1 5 7
20. Consider the following three claims
I. (n + k)
m
= T(n
m
) where k and m are constants
II. 2
n+1
= O(2
n
)
III. 2
2n+1
= O(2
n
)
Which of these claims are correct?
(A) I and II (B) I and III (C) II and III (D) I, II, and III
21. Consider the following graph
Among the following sequences
I a b e g h f II a b f e h g III a b f h g e IV a f g h b e
Which are depth first traversals of the above graph?
(A) I, II and IV only (B) I and IV only
(C) II, III and IV only (D) I, III and IV only
22. The usual T(n
2
) implementation of Insertion Sort to sort an array uses linear
search to identify the position where an element is to be inserted into the already
sorted part of the array. If, instead, we use binary search to identify the position,
the worst case running time will
(A) remain T(n
2
) (B) become T(n (log n)
2
)
(C) become T(n log n) (D) become T(n)
Page 5
GATE CS  2003
Q.1 — Q.30 carry one mark each.
1. Consider the following C function.
float f,(float x, int y) {
float p, s; int i;
for (s=1,p=1,i=1; i<y; i++) {
p *= x/i;
s+=p;
}
return s;
}
For large values of y, the return value of the function f best approximates
(A)
y
X (B) e
x
(C) ln(1+x) (D)
x
X
2. Assume the following C variable declaration
int * A[10], B[10][10];
Of the following expressions
I. A[2] II. A[2][3] III. B[1] IV. B[2][3]
which will not give compiletime errors if used as left hand sides of assignment
statements in a C program?
(A) I,II, and IV only (B) II, III, and IV only
(C) II and IV only (D) IV only
3. Let P(E) denote the probability of the event E. Given P(A) = 1, P(B) =
1
2
, the
values of P(AB) and P(BA) respectively are
(A)
1
4
,
1
2
(B)
1
2
,
1
4
(C)
1
2
, 1 (D) 1,
1
2
4. Let A be a sequence of 8 distinct integers sorted in ascending order. How many
distinct pairs of sequences, B and C are there such that (i) each is sorted in
ascending order, (ii) B has 5 and C has 3 elements, and (iii) the result of merging
B and C gives A?
(A) 2 (B) 30 (C) 56 (D) 256
5. n couples are invited to a party with the condition that every husband should be
accompanied by his wife. However, a wife need not be accompanied by her
husband. The number of different gatherings possible at the party is
(A)
2
*2
n
n
n
? ?
? ?
? ?
(B) 3
n
(C)
( ) 2 !
2
n
n
(D)
2n
n
? ?
? ?
? ?
GATE CS  2003
6. Let T(n) be the number of different binary search trees on n distinct elements.
Then T(n)= ( ) ( )
1
1 ,
n
k
T k T x
=

?
where x is
(A) n – k + 1 (B) n – k (C) n – k – 1 (D) n – k – 2
7. Consider the set S* of all strings over the alphabet S = {0, 1}. S* with the
concatenation operator for strings
(A) does not form a group
(B) forms a noncommutative group
(C) does not have a right identity element
(D) forms a group if the empty string is removed from S*
8. Let G be an arbitrary graph with n nodes and k components. If a vertex is
removed from G, the number of components in the resultant graph must
necessarily lie between
(A) k and n (B) k – 1 and k + 1
(C) k – 1 and n – 1 (D) k + 1 and n – k
9. Assuming all numbers are in 2’s complement representation, which of the
following numbers is divisible by 11111011?
(A) 11100111 (B) 11100100 (C) 11010111 (D) 11011011
10. For a pipelined CPU with a single ALU, consider the following situations
I. The j + 1st instruction uses the result of the jth instruction as an operand
II. The execution of a conditional jump instruction
III. The jth and j + 1st instructions require the ALU at the same time
Which of the above can cause a hazard?
(A) I and II only (B) II and III only (C) III only (D) All the three
11. Consider an array multiplier for multiplying two n bit numbers. If each gate in the
circuit has a unit delay, the total delay of the multiplier is
(A) T (1) (B) T (log n) (C) T (n) (D) T (n
2
)
12. Ram and Shyam have been asked to show that a certain problem ? is NP
complete. Ram shows a polynomial time reduction from the 3SAT problem to ?,
and Shyam shows a polynomial time reduction from ? to 3SAT. Which of the
following can be inferred from these reductions?
(A) ? is NPhard but not NPcomplete (B) ? is in NP, but is not NPcomplete
(C) ? is NPcomplete (D) ? is neither NPhard, nor in NP
GATE CS  2003
13. Nobody knows yet if P = NP. Consider the language L defined as follows.
( ) 0 1 * if
otherwise
P NP
L
f
? + =
?
=
?
?
?
Which of the following statements is true?
(A) L is recursive
(B) L is recursively enumerable but not recursive
(C) L is not recursively enumerable
(D) Whether L is recursive or not will be known after we find out if P = NP
14. The regular expression 0*(10*)* denotes the same set as
(A) (1*0)*1* (B) 0+(0+10)*
(C) (0+1)*10(0+1)* (D) None of the above
15. If the strings of a language L can be effectively enumerated in lexicographic (i.e.,
alphabetic) order, which of the following statements is true?
(A) L is necessarily finite
(B) L is regular but not necessarily finite
(C) L is context free but not necessarily regular
(D) L is recursive but not necessarily context free
16. Which of the following suffices to convert an arbitrary CFG to an LL(1) grammar?
(A) Removing left recursion alone
(B) Factoring the grammar alone
(C) Removing left recursion and factoring the grammar
(D) None of the above
17. Assume that the SLR parser for a grammar G has n
1
states and the LALR parser
for G has n
2
states. The relationship between n
1
and n
2
is
(A) n
1
is necessarily less than n
2
(B) n
1
is necessarily equal to n
2
(C) n
1
is necessarily greater than n
2
(D) None of the above
18. In a bottomup evaluation of a syntax directed definition, inherited attributes can
(A) always be evaluated
(B) be evaluated only if the definition is Lattributed
(C) be evaluated only if the definition has synthesized attributes
(D) never be evaluated
GATE CS  2003
19. Suppose the numbers 7, 5, 1, 8, 3, 6, 0, 9, 4, 2 are inserted in that order into an
initially empty binary search tree. The binary search tree uses the usual ordering
on natural numbers. What is the inorder traversal sequence of the resultant
tree?
(A) 7 5 1 0 3 2 4 6 8 9 (B) 0 2 4 3 1 6 5 9 8 7
(C) 0 1 2 3 4 5 6 7 8 9 (D) 9 8 6 4 2 3 0 1 5 7
20. Consider the following three claims
I. (n + k)
m
= T(n
m
) where k and m are constants
II. 2
n+1
= O(2
n
)
III. 2
2n+1
= O(2
n
)
Which of these claims are correct?
(A) I and II (B) I and III (C) II and III (D) I, II, and III
21. Consider the following graph
Among the following sequences
I a b e g h f II a b f e h g III a b f h g e IV a f g h b e
Which are depth first traversals of the above graph?
(A) I, II and IV only (B) I and IV only
(C) II, III and IV only (D) I, III and IV only
22. The usual T(n
2
) implementation of Insertion Sort to sort an array uses linear
search to identify the position where an element is to be inserted into the already
sorted part of the array. If, instead, we use binary search to identify the position,
the worst case running time will
(A) remain T(n
2
) (B) become T(n (log n)
2
)
(C) become T(n log n) (D) become T(n)
GATE CS  2003
23. In a heap with n elements with the smallest element at the root, the 7th smallest
element can be found in time
(A) T(n log n) (B) T(n) (C) T(log n) (D) T(1)
24. Which of the following statements is FALSE?
(A) In statically typed languages, each variable in a program has a fixed type
(B) In untyped languages, values do not have any types
(C) In dynamically typed languages, variables have no types
(D) In all statically typed languages, each variable in a program is associated
with values of only a single type during the execution of the program
25. Using a larger block size in a fixed block size file system leads to
(A) better disk throughput but poorer disk space utilization
(B) better disk throughput and better disk space utilization
(C) poorer disk throughput but better disk space utilization
(D) poorer disk throughput and poorer disk space utilization
26. In a system with 32 bit virtual addresses and 1KB page size, use of onelevel
page tables for virtual to physical address translation is not practical because of
(A) the large amount of internal fragmentation
(B) the large amount of external fragmentation
(C) the large memory overhead in maintaining page tables
(D) the large computation overhead in the translation process
27. Which of the following assertions is FALSE about the Internet Protocol (IP)?
(A) It is possible for a computer to have multiple IP addresses
(B) IP packets from the same source to the same destination can take different
routes in the network
(C) IP ensures that a packet is discarded if it is unable to reach its destination
within a given number of hops
(D) The packet source cannot set the route of an outgoing packets; the route is
determined only by the routing tables in the routers on the way
28. Which of the following functionalities must be implemented by a transport
protocol over and above the network protocol?
(A) Recovery from packet losses (B) Detection of duplicate packets
(C) Packet delivery in the correct order (D) End to end connectivity
Read More