CS - 2007 - by WWW - LearnEngineering.in
CS - 2007 - by WWW - LearnEngineering.in
in
No part of this publication may be reproduced or distributed in any form or any means, electronic, mechanical,
photocopying, or otherwise without the prior permission of the author.
n
n g.i
GATE SOLVED PAPER
Computer Science Engineering
2007
e eri
gin
Copyright © By NODIA & COMPANY
En
arn
Information contained in this book has been obtained by authors, from sources believes to be reliable. However,
neither Nodia nor its authors guarantee the accuracy or completeness of any information herein, and Nodia nor its
authors shall be responsible for any error, omissions, or damages arising out of use of this information. This book
is published with the understanding that Nodia and its authors are supplying information but are not attempting
.Le
www.LearnEngineering.in
www.LearnEngineering.in
Q. 1 The height of a binary tree is the maximum number of edges in any root to leaf
path. The maximum number of nodes is a binary tree of height h is
(A) 2h (B) 2h 1- 1-
n
(C)2h 1+ 1- (D) 2h 1+
g.i
Q. 2 The maximum number of binary trees that can be formed with three unlabeled
nodes is
(A) 1 (B) 5
n
(C) 4 (D) 3
Q. 3
(A) Merge sort
(C) Quick sort
e eri
Which of the following sorting algorithms has the lowest worst-case complexity?
(B) Bubble sort
(D) Selection sort
gin
Q. 4 The inorder and preorder traversal of a binary tree are
dbeafcg andabdecfg respectively
The postorder traversal of the binary tree is
(A) debfgca (B) edbgfca
En
Q. 5 Consider the hash table of size seven, with starting index zero, and a has function
(3x 4+) and 7. Assuming the has table is initially empty, which of the following
arn
is the contents of the table when the sequence 1,3,8,10 is inserted into the table
using closed hashing?
Note that-denotes an empty location in the table
.Le
(C) performing a DFS starting from S (D) preforming a BFS starting from S
Q. 7 A complete n-ary tree is a tree in which each node has n children or no children.
Let I be the number of internal nodes and L be the number of leaves in a
complete n-ary tree. If L= 41, and I =10, what is the value of n
(A) 3 (B) 4
(C) 5 (D) 6
www.LearnEngineering.in
www.LearnEngineering.in
return gcd(m,n);
}
How many recursive calls are made by this function?
(A) (Q
log2 n) (B) (W n)
(C) (Q
log2 log2 n) (D) (Q n )
n
else
return(DoSomething(floor(sqrt(n))
g.i
)+ n);
}
(A) (Qn2) (B) (Q n log2 n)
n
(C) (Qlog2 n) (D) (Q log2 log2 n)
eri
Q. 10 Consider the process of inserting an element into a Max Heap, where the Max
Heap is represented by an array. Suppose we perform a binary search on the path
from the new leaf to the root to find the position for the newly inserted element,
e
the number of comparisons performed is
gin
q 2 n)
(A) (log q 2 log2 n)
(B) (log
(C) nq (D) (n q log2 n)
Q. 11 Let w be the minimum weight among all edge weights in an undirected connected
En
www.LearnEngineering.in
www.LearnEngineering.in
Let T (n) denote the number of times the for loop is executed by the program on
input n . Which of the following is TRUE?
(A) T (n) = O ( n ) and T (n) + (W n ) (B) T (n) = O ( n ) and T (n) + (W 1)
(C) T (n) = O (n) and T (n) = (W n ) (D) None of these
n
Q. 14 Which of the following is the Hoffman code for the letters a, b, c, d, e, f ?
(A) 0, 10, 110, 1110, 11110, 11111 (B) 11, 10, 011, 010, 001, 000
g.i
(C) 11, 10, 01, 001, 0001, 0000 (D) 110, 100, 010, 000, 111
n
(A) 3 (B) 2.1875
eri
(C) 2.25 (D) 1.781
T = {a, b, i, t, e}, with S as the start symbol, and the following of rules
S " iCtSS1 | a ; S1 " eS | ; eC " b
The grammar is NOTLL(1) because:
arn
www.LearnEngineering.in
www.LearnEngineering.in
t 4 t1 =t2 -
Assume that all operands are initially in memory. The final value of the computation
should be in memory. What is the minimum number of MOV instructions in the
code generated for this basic block?
(A) 2 (B) 3
(C) 5 (D) 6
n
Consider the CFG with {S, A, B} as the non-terminal alphabet, {a, b} as the
g.i
terminal alphabet, S as the start symbol and the following set of production rules
s " bA S " aB
A"a B"b
A " aS B " bS
n
A " bAA B " aBB
Q. 20
(A) aaaabb
(C) aabbab
e eri
Which of the following strings is generated by the grammar?
(B) aabbbb
(D) abbbba
gin
Q. 21 For the correct answer string to Q. 9 how many derivation trees are there?
(A) 1 (B) 2
(C) 3 (D) 4
En
Q. 24 There are n stations in a slotted LAN. Each station attempts to transmit with a
probability p in each time slot. What is the probability that ONLY one station
transmits in a given time slot?
w
Q. 25 In a token ring network the transmission speed is 10 bps and the propagation
speed is 200 metres/ s m. The 1-bit delay in this network is equivalent to;
(A) 500 metres of cable (B) 200 metres of cable
(C) 20 metres of cable (D) 50 metres of cable
Q. 26 The address of a class B host is to be split into subnets with a 6-bit subnet
number. What is the maximum number of subnets and the maximum number of
hosts in each subnet?
(A) 62 subnets and 262142 hosts (B) 64 subnets and 262142 hosts
(C) 62 subnets and 1022 hosts (D) 64 subnets and 1024 hosts
www.LearnEngineering.in
www.LearnEngineering.in
Q. 28 The distance between two stations M and N is L kilo metres. All frames are K
bits long. The propagation delay per kilo metre is t seconds Let R bits/second be
the channel capacity. Assuming that processing delay is negligible, the minimum
number of bits for the sequence number field in a frame for maximum utilization,
when the sliding window protocol is used, is;
(A) :log2 2LtR 2+K D (B) :log2 2LtR D
n
K K
g.i
(C) :log2 2LtR + K D (D) :log2 2LtR K+D
K 2K
n
Q. 29 Match the following:
P. SMTP 1. Application layer
Q. BGP
R. TCP
S. PPP
e eri 2. Transport layer
3. Data link layer
4. Network layer
5. Physical layer
gin
(A) P-2,Q-1,R-3,S-5 (B) P-1,Q-4,R-2,S-3
(C) P-1,Q-4,R-2,S-5 (D) P-2,Q-4,R-1,S-3
En
Q. 30 Consider a 4-way set associative cache consisting of 120 lines with a line size of
64 words. The CPU generates a 20-bit address of a word in main memory. The
number of bits in the TAG, LINE and WORD fields are respectively
(A) 9,6,5 (B) 7,7,6
arn
Q. 31 Consider a disk pack with 16 surfaces, 128 tracks per surface and 256 sectors per
track. 512 bytes of data are stored in a bit serial manner in a sector. The capacity
.Le
of the disk pack and the number of bits required to specify a particular sector in
the disk are respectively
(A) 256 Mbytes, 19 bits (B) 256 Mbyte, 28 bits
(C) 512 Mbytes, 20 bits (D) 64 Gbyte, 28 bits
w
ww
www.LearnEngineering.in
www.LearnEngineering.in
n
purpose registers.
g.i
Instruction Operation Instruction size
(no. of words)
MOV R1,(3000) R1!M[3000] 2
n
LOOP:
eri
MOV R2,R1 R2!M[R3] 1
ADD R2,R1 R2!R1+R2 1
MOV (R3),R2 M(R3]!R2 1
e
INC R3 R3!R3+1 1
gin
DEC R1 R1!R1-1 1
BNZ LOOP Branch on not zero 2
HALT Stop
En
Assume that the content of memory location 3000 is 10 and the content of the
register R3 is 2000. The content of each of the memory locations from 2000
to 2010 is 100. The program is loaded from the memory location 100. All the
numbers are in decided.
arn
Q. 33 Assume that the memory is word addressable. The number of memory references
for accessing the data in executing the program completely is
(A) 10 (B) 11
.Le
(C) 20 (D) 21
Q. 34 Assume that the memory is word addressable. After the execution of this program,
w
Q. 35 Assume that the memory is byte addressable and the word size is 32 bits. If an
interrupt occurs during the execution of the instruction “INC R3”, what return
address will be pushed on to the stack?
(A) 1005 (B) 1020
(C) 1024 (D) 1040
www.LearnEngineering.in
www.LearnEngineering.in
n
(C) 56 (D) 59
g.i
Q. 37 Which of the following lines of the data cache will be replaced by new blocks in
accessing the array
(A) line 4 to line 11 (B) line 4 to line 12
n
(C) line 0 to line 7 (D) line 0 to line 8
eri
Q. 38 Information about a collection of students is given by the relation studInfo
(studId, name, sex). The relation enroll (studID, CourseId) gives which student
has enrolled for (or taken) what course(s). Assume that every course is taken
e
by at least one male and at least one female student. What does the following
gin
relational algebra expression represent?
courseld (( PstudId ( sex
s "female"
= P
(studInfo)) # courseId (enroII)) enroII) P -
(A) Courses in which all the female students are enrolled
(B) Courses in which a proper subset of female students are enrolled
En
Q. 39 Consider the relation employee (name, sex, supervisorName (with name as the
key. supervisor Name-gives the name of the supervisor of the employee under
consideration. What does the following Tuple Relational Calculus query produce?
{e.name|employee(e) 0
.Le
Q. 40 Consider the table employee (empId, name, department, salary) and the two
queries Q1, Q2 below. Assuming that department 5 has more than one employee,
and we want to find the employees who get higher salary than anyone in the
department 5, which one of the statements is TRUE for any arbitrary employee
table?
Q1 : Select e. empId
From employee e
Where not exists
(Select*From employee s Where s. department=”5” and s.salay>=e.salary)
Q.2 : Select e. empId
www.LearnEngineering.in
www.LearnEngineering.in
From employee e
Where e.salary>Any
(Select distinct salary From employee s Where s. department=”5”)
(A) Q1 is the correct query.
(B) Q2 is the correct query
(C) Both Q1 and Q2 produce the same answer
(D) Neither Q1 nor Q2 is the correct query
n
(A) Any relation with two attributes is in BCNF
(B) A relation in which every key has only one attribute is in 2NF
g.i
(C) A prime attribute can be transitively dependent on a key in 3NF relation
(D) A prime attribute can be transitively dependent on a key in a BNCF relation.
n
Q. 42 The order of a leaf node in a B + tree- is the maximum number of (value, data
eri
record pointer) pairs it can hold. Given that the block size is 1K bytes, data
record pointer is 7 bytes long, the value field is 9 bytes long and a block pointer
is 6 bytes long, what is the order of the leaf node?
(A) 63
e (B) 64
(C) 67 (D) 68
gin
Q. 43 Consider the following schedules involving two transactions. Which one of the
following statements is TRUE?
S1:r1 (X); r1 (Y); r2 (X); r2 (Y); w2 (Y); w1 (X); S2:r1 (X); r2 (X); r2 (Y); w2 (Y); r1 (Y); w1 (X)
En
(A) n2 (B) 2n
(C) 22 (D) 2n
n 2
Q. 45 How many 3-to-8 line decoders with an enable input are needed to construct a
w
(C) 9 (D) 10
Q. 47 Let f (w, x, y, z) =
/ (0, 4, 5, 7, 8, 9, 13, 15). Which of the following expressions are
NOT equivalent to f ?
(A) x'y'z w'xy' +wy'z xz + (B) w+'y'x' wx'y' +xz +
(C) w'y'z' wx'y' +xyz xy'z + (D) x+'y'z wx'y' +w'y +
www.LearnEngineering.in
www.LearnEngineering.in
Q. 48 Define the connective* for the boolean variable X and Y as: X * Y XY =X'Y' +
Let Z = X * Z
Consider the following expression P, Q and R.
P: X Y * ZQ: Y = X * Z =
R: X * Y * Z =1
Which of the following is TRUE?
(A) only P and Q are valid (B) Only Q and Rare valid
(C) Only P and Rare valid (D) All P, Q ,Rare valid
Q. 49 Suppose only one multiplexer and one inverter are allowed to be used to implement
n
any Boolean function of n variables. What is the minimum size of the multiplexer
g.i
needed?
(A) 2n line to 1 line (B) 2n 1+ line to 1 line
(C) 2n 1- line to 1 line (D) 2n 2- line to 1 line
n
eri
Q. 50 In a look-ahead carry generator, the carry generate function Gi and the carry
propagate function Pi for inputs, Ai and Bi are given by Pi = Ai 5 Bi and Gi =
Ai Bi
The expressions for the sum bit S and carry bit Ci 1+ of the look ahead carry
adder are given by
e
Si P +i 5 Ci and Ci 1+Gi P +i Ci , Where C0 is the input carry.
gin
Consider a two-level logic implementation of the look-ahead carry generator..
Assume that all Pi and Gi are available for the carry generator circuit and that
the AND and OR gates can have any number of inputs. The number of AND
En
gates and OR gates needed to implement the look-ahead carry generator for a
4-bit adder with S3, S2, S1, S0 and C4 as its outputs are respectively
(A) 6,3 (B) 10,4
(C) 6,4 (D) 10,5
arn
Q. 51 The control signal functions of 4-bit binary counter are given below
(where X is “don’t care”)
.Le
0 - 1 X Load input
0 0 1 Count next
ww
-
The counter is connected as follows
www.LearnEngineering.in
www.LearnEngineering.in
Assume that the counter and gate delays are negligible. If the counter starts at 0,
then it cycles through the following sequence
(A) 0,3,4 (B) 0,3,4,5
(C) 0,1,2,3,4 (D) 0,1,2,3,4,5
Q. 52 Let S be a set of n elements. The number of ordered pairs in the largest and the
smallest equivalence relations on S are
(A) n and n (B) n2 and n
(C) n2 and 0 (D) n and 1
n
Q. 53 Let G be the non-planar graph with the minimum possible number of edges.
Then G has.
g.i
(A) 9 edges and 5 vertices (B) 9 edges and 6 vertices
(C) 10 edges and 5 vertices (D) 10 edges and 6 vertices
n
Q. 54 Consider the DAG with V =
{1, 2, 3, 4, 5.6}, shown below
e eri
gin
(C) 1 3 2 4 5 6 (D) 3 2 4 1 6 5
Q. 55 Consider the following two statements about the function f (x^ |=x |h
arn
(C) Both P and Q are true (D) Both P and Q are false
Q. 56 Let Graph (x) be a predicate which denotes that x is a graph. Let connected (x)
be a predicate which denotes that x is connected. Which of the following first
w
order logic sentences DOES NOT represent the statement; ‘Not every graph is
connected”?
ww
(A) J6x (Graph(x) & Connected (x)) (B) 7x (Graph(x) /J Connected (x))
(C) J6x (JGraph(x) 0 Connected (x)) (D) 6x (Graph(x) & J Connected (x))
www.LearnEngineering.in
www.LearnEngineering.in
Q. 58 Suppose we uniformly and randomly select a permutation from the 20! permutations
of 1, 2, 3. 20. What is the probability that 2 appears at an earlier position that
any other even number in the selected permutation?
(A) 1/2 (B) 1/10
(C) 9! (D) None of these
20!
Q. 59 How many different non-iscomorphic Abelian groups of order 4 are there?
(A) 2 (B) 3
(C) 4 (D) 5
n
Q. 60 Consider the set S = {a, b, c, d}. Consider the following 4 partitions 1, p2, 3, 4p, on p p
S: 1 {abcd }, p2 {ab, cd }, 3 = {abc, d }, 4pp = p partial =
{a, b, c, d }. Let ' be the
g.i
order on the set of partitions S' = ( 1, p2. 3, 4p) defined
p as pfollows: i ' pj if and p
only if i prefines j .pThe poset diagram for (S', ') is
n
e eri
gin
En
arn
.Le
Q. 61 How many distinct paths are there for the robot to reach the point (10, 10)
starting from the initial position (0, 0)?
20
(A) d n (B) 220
10
(C) 210 (D) None of these
Q. 62 Suppose that the robot is not allowed to traverse the line segment from (4, 4) to
(5, 4). With this constraint, how many distinct paths are there for the robot to
reach (10, 10) starting from (0, 0)?
(A) 29 (B) 219
8 11 20 8 11
(C) d n # d n (D) d n d- n # d n
4 5 10 4 5
www.LearnEngineering.in
www.LearnEngineering.in
n
Where I is the 4 # 4 identity matrix?
g.i
(A) 5- (B) 7-
(C) 2 (D) 1
n
Q. 65 Consider the set of (column) vectors defined tyX =
{x ! R' | x1 x2 +x 3 0 + =
T T
where x =
x1, x2, x3] }.
eri
Which of the following is TRUE?
- T , [1,0, 1-]T } is a basis for the subspace X.
(A) {[1, 1,0]
(B) {[1, 1, 0]T ,[ 1, 0, -1]T } is a linearly independent
- set, but it does not span
e
X and therefore is not a basis of X
gin
(C) X is not a subspace for R3
(D) None of the above
1+
2 8xn 0
method. The series converges to
(A) 1.5 (B) 2
arn
Q. 67 Group-1 contains some CPU scheduling algorithms and group-2 contains some
applications. Match entries in Group-1 entries in Group-2
Group-1 Group-2
.Le
Q. 68 Consider the following statements about user level threads and kernel level
threads. Which one of the following statements is FALSE?
(A) Context switch time is longer for kernel level threads than for user level
threads
(B) User level threads do not need any hardware support
(C) Related kernal level thread can be scheduled on different processors in a
multiprocessor system
(D) Blocking one kernel level thread blocks all related threads
www.LearnEngineering.in
www.LearnEngineering.in
Q. 69 An operating system uses Shortest Remaining Time first (SRT) process scheduling
algorithm. Consider the arrival times and execution times for the following
processes
n
What is the total waiting time for process P2?
(A) 5 (B) 15
g.i
(C) 40 (D) 55
n
Q. 70 A virtual memory system uses first In First Out (FIFO) page replacement policy
eri
and allocates a fixed number of frames to a process. Consider the following
statements:
P: Increasing the number of page frames allocated to a process sometimes increases
the page fault rate.
e
gin
Q: Some program do not exhibit locality of reference.
Which one of the following is TRUE?
(B) Both P and Q are true, but Q is not the reason for P
(C) P is false, but Q is true
(D) Both P and Q are false
arn
Q. 71 A single processor system has three resource types X, Y, and Z, which are shared
by three processes. There are 5 units of each resource type. Consider the following
.Le
scenario, where the column alloc denotes the number of units of each resource
type allocated to each process, and the column request denotes the number of
units of each resource type requested by a process in order to complete execution.
Which of these processes will finish LAST?
w
alloc request
ww
XYZ XYZ
P0 121 103
P1 201 012
P2 221 120
(A) P0
(B) P1
(C) P2
(D) None of the above, since the system is in a deadlock
www.LearnEngineering.in
www.LearnEngineering.in
Q. 72 Two processes, P1 and P2, need to access a critical section of code. Consider the
following synchronization construct used by the processes:
/*P1*/ /*P2*/
while (true) { while (true) {
wants1=true; wants2 = true;
while (wants1 ==
while(wants2==true); true);
/* Critical /* Critical
Section*/ Section*/
wants 1 = false; wants 2 = false;
n
} }
/* Remainder section*/ /*Remainder section*/
g.i
Here, wants 1 and wants 2 are shared variables, Which are initialized to false.
Which one of the following statements is TRUE about the above construct?
n
(A) It does not ensure mutual exclusion.
(B) It does not ensure bounded waiting.
eri
(C) It requires that processes enter the critical section in strict alternation.
(D) It does not prevent deadlocks, but ensures mutual exclusion
e
gin
Common Data For Q. 73 and 74
A process has been allocated 3 page frames. Assume that none of the pages of
the process are available in the memory initially. The process makes the following
En
(A) 0 (B) 1
(C) 2 (D) 3
ww
www.LearnEngineering.in
www.LearnEngineering.in
Q. 76 The following postfix expression with single digit operands in evaluated using a
stack
823^23*+51*-
Note that^is the exponentiation operator. The top two elements of the stack after
the first* is evaluated are
(A) 6, 1 (B) 5, 7
(C) 3, 2 (D) 1, 5
n
static int r=0;
if (n<=0) return 1;
g.i
if (n>3)
{r=n;
return f(n-2)+2;
n
}
eri
return f(n-1)+r;
}
What is the value of f(5) ?
(A) 5 (B) 7
e
(C) 9 (D) 18
gin
Q. 78 Consider the following C program segment where Cell Node represents a node in
a binary tree
struct CellNode {
En
struct CellNode*leftchild;
int element;
struct CellNode*rightchild;
arn
};
int GetValue(struct CellNode * ptr) {
int vlaue = 0;
if (ptr!=NULL) {
.Le
if ((ptr->leftChild = = NULL)&&
(ptr->rightChild = = NULL))
Value = 1;
else
w
+ Get Value
(ptr->rightChild);
}
return(value);
}
The value returned by Get Value when a pointer to the root of a binary tree is
passed as its argument is
(A) the number of nodes in the tree
(B) the number of internal nodes in the tree
(C) the number of leaf nodes in the tree
(D) the height of the tree
www.LearnEngineering.in
www.LearnEngineering.in
n
Q. 81 A minimum state deterministic finite automation accepting the language
L = {w | w ! (0, 1}* , number of 0s &1s in w are divisible by 3 and 5, respectively}
g.i
has
(A) 15 states (B) 11 states
(C) 10 states (D) 9 states
n
eri
Q. 82 The language L = {0T 21i | i # 0} over the alphabet {0,1,2) is
(A) not recursive
(B) is recursive and is a deterministic CFL
e
(C) us a regular language
gin
(D) is not a deterministic CFI but a CFL
Q. 85 The minimum state automaton equivalent to the above FSA has the following
number of states
(A) 1 (B) 2
(C) 3 (D) 4
**********
www.LearnEngineering.in
www.LearnEngineering.in
ANSWER KEY
2007
1 2 3 4 5 6 7 8 9 10
(C) (B) (A) (A) (B) (D) (C) (C) (D) (A)
11 12 13 14 15 16 17 18 19 20
(D) (D) (B) (A) (D) (A) (C) (B) (B) (C)
21 22 23 24 25 26 27 28 29 30
(B) (B) (C) (A) (C) (C) (D) (B) (B) (B)
n
31 32 33 34 35 36 37 38 39 40
g.i
(A) (B) (D) (A) (A) (C) (C) (B) (B) (B)
41 42 43 44 45 46 47 48 49 50
(B) (B) (C) (C) (B) (B) (D) (D) (C) (C)
n
51 52 53 54 55 56 57 58 59 60
(D)
61
(A)
(B)
62
(D)
(B)
63
(A)
(D)
64
(D)
(A)
65
(B)
e eri
(D)
66
(A)
(B)
67
(A)
(D)
68
(D)
(B)
69
(B)
(C)
70
(B)
gin
71 72 73 74 75 76 77 78 79 80
(C) (D) (A) (C) (D) (A) (D) (C) (B) (B)
81 82 83 84 85
(A) (B) (C) (C) (B)
En
arn
w .Le
ww
www.LearnEngineering.in