SlideShare a Scribd company logo
GATE CS - 2001 www.gateforum.com
Join discussion of this test paper at http://forum.gatementor.com
Join All India Mock GATE Classroom Test Series - 2007 conducted by GATE Forum in over 25 cities all over India. Question
Papers including section tests and full tests are designed by IISc alumni according to the latest syllabus. Percentile, All India Rank,
interaction with IISc alumni in our online discussion forums, and more. For more details,
visit
www.gateforum.com
Think GATE Think GATE Forum
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: (P⇒¬P)∨(¬P⇒P)
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 1n
n ≥ is a regular language
S2: { }0 1 0 1 and 1m 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 www.gateforum.com
Join discussion of this test paper at http://forum.gatementor.com
Join All India Mock GATE Classroom Test Series - 2007 conducted by GATE Forum in over 25 cities all over India. Question
Papers including section tests and full tests are designed by IISc alumni according to the latest syllabus. Percentile, All India Rank,
interaction with IISc alumni in our online discussion forums, and more. For more details,
visit
www.gateforum.com
Think GATE Think GATE Forum
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) N2
(b) 2N
(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 program’s 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 www.gateforum.com
Join discussion of this test paper at http://forum.gatementor.com
Join All India Mock GATE Classroom Test Series - 2007 conducted by GATE Forum in over 25 cities all over India. Question
Papers including section tests and full tests are designed by IISc alumni according to the latest syllabus. Percentile, All India Rank,
interaction with IISc alumni in our online discussion forums, and more. For more details,
visit
www.gateforum.com
Think GATE Think GATE Forum
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) w x 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(n2
) (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 (i≤n), 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 www.gateforum.com
Join discussion of this test paper at http://forum.gatementor.com
Join All India Mock GATE Classroom Test Series - 2007 conducted by GATE Forum in over 25 cities all over India. Question
Papers including section tests and full tests are designed by IISc alumni according to the latest syllabus. Percentile, All India Rank,
interaction with IISc alumni in our online discussion forums, and more. For more details,
visit
www.gateforum.com
Think GATE Think GATE Forum
1.16 Let ( ) ( ) ( )102
log and logf 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 r1, r2, …. rn 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 www.gateforum.com
Join discussion of this test paper at http://forum.gatementor.com
Join All India Mock GATE Classroom Test Series - 2007 conducted by GATE Forum in over 25 cities all over India. Question
Papers including section tests and full tests are designed by IISc alumni according to the latest syllabus. Percentile, All India Rank,
interaction with IISc alumni in our online discussion forums, and more. For more details,
visit
www.gateforum.com
Think GATE Think GATE Forum
1.23 Consider a schema R(A,B,C,D) and functional dependencies A B and C D.
Then the decomposition of R into R1 (AB) and R2(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∩(B∪C) 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 www.gateforum.com
Join discussion of this test paper at http://forum.gatementor.com
Join All India Mock GATE Classroom Test Series - 2007 conducted by GATE Forum in over 25 cities all over India. Question
Papers including section tests and full tests are designed by IISc alumni according to the latest syllabus. Percentile, All India Rank,
interaction with IISc alumni in our online discussion forums, and more. For more details,
visit
www.gateforum.com
Think GATE Think GATE Forum
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(E∪F)=f(E) ∪f(F)
S2:f(E∩F)=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 a’s
divisible by 6 and number of b’s 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 wR R
L ww w a b w= ∈
{ }2
3 0 i is an integeri
L =
{ }2
3 0 i is an integeri
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 www.gateforum.com
Join discussion of this test paper at http://forum.gatementor.com
Join All India Mock GATE Classroom Test Series - 2007 conducted by GATE Forum in over 25 cities all over India. Question
Papers including section tests and full tests are designed by IISc alumni according to the latest syllabus. Percentile, All India Rank,
interaction with IISc alumni in our online discussion forums, and more. For more details,
visit
www.gateforum.com
Think GATE Think GATE Forum
2.8 Consider the following circuit with initial state Q0 = Q1 = 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 C≥40
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
0Q
C
X
GATE CS - 2001 www.gateforum.com
Join discussion of this test paper at http://forum.gatementor.com
Join All India Mock GATE Classroom Test Series - 2007 conducted by GATE Forum in over 25 cities all over India. Question
Papers including section tests and full tests are designed by IISc alumni according to the latest syllabus. Percentile, All India Rank,
interaction with IISc alumni in our online discussion forums, and more. For more details,
visit
www.gateforum.com
Think GATE Think GATE Forum
2.10 The 2’s 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 2f x x′= + (b) 1 2 1 2f x x x x′ ′= +
(c) 1 2 1 2f x x x x′ ′= + (d) 1 2f x x ′= +
2.12 Consider the circuit given below with initial state Q0 =1, Q1 = Q2 = 0. The state of
the circuit is given by the value 2 1 04 2Q 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 www.gateforum.com
Join discussion of this test paper at http://forum.gatementor.com
Join All India Mock GATE Classroom Test Series - 2007 conducted by GATE Forum in over 25 cities all over India. Question
Papers including section tests and full tests are designed by IISc alumni according to the latest syllabus. Percentile, All India Rank,
interaction with IISc alumni in our online discussion forums, and more. For more details,
visit
www.gateforum.com
Think GATE Think GATE Forum
2.13 Consider the following data path of a simple non-pilelined CPU. The registers A,
B, A1, A2, 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, , nV v v v= K of n vertices?
(a)
( )1
2
n n −
(b) 2n
(c) n! (d)
( )1
22
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 MDRSPdcr
GATE CS - 2001 www.gateforum.com
Join discussion of this test paper at http://forum.gatementor.com
Join All India Mock GATE Classroom Test Series - 2007 conducted by GATE Forum in over 25 cities all over India. Question
Papers including section tests and full tests are designed by IISc alumni according to the latest syllabus. Percentile, All India Rank,
interaction with IISc alumni in our online discussion forums, and more. For more details,
visit
www.gateforum.com
Think GATE Think GATE Forum
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 www.gateforum.com
Join discussion of this test paper at http://forum.gatementor.com
Join All India Mock GATE Classroom Test Series - 2007 conducted by GATE Forum in over 25 cities all over India. Question
Papers including section tests and full tests are designed by IISc alumni according to the latest syllabus. Percentile, All India Rank,
interaction with IISc alumni in our online discussion forums, and more. For more details,
visit
www.gateforum.com
Think GATE Think GATE Forum
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 www.gateforum.com
Join discussion of this test paper at http://forum.gatementor.com
Join All India Mock GATE Classroom Test Series - 2007 conducted by GATE Forum in over 25 cities all over India. Question
Papers including section tests and full tests are designed by IISc alumni according to the latest syllabus. Percentile, All India Rank,
interaction with IISc alumni in our online discussion forums, and more. For more details,
visit
www.gateforum.com
Think GATE Think GATE Forum
2.22 Consider Peterson’s 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 2t 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) ( ){ }1t t R¬ ∈
(d) ( ) ( ){ }1 2t 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 y≥x.
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 www.gateforum.com
Join discussion of this test paper at http://forum.gatementor.com
Join All India Mock GATE Classroom Test Series - 2007 conducted by GATE Forum in over 25 cities all over India. Question
Papers including section tests and full tests are designed by IISc alumni according to the latest syllabus. Percentile, All India Rank,
interaction with IISc alumni in our online discussion forums, and more. For more details,
visit
www.gateforum.com
Think GATE Think GATE Forum
(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: N×N 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 DFA’s for the following languages:
(a) { }{ }, *, w has baab as a subsringL w w a b= ∈
(b) { }{ }, *, w has an odd number of a's and an odd nuber of b'sL w w a b= ∈
6. Give a deterministic PDA for the language { }2
1n 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 www.gateforum.com
Join discussion of this test paper at http://forum.gatementor.com
Join All India Mock GATE Classroom Test Series - 2007 conducted by GATE Forum in over 25 cities all over India. Question
Papers including section tests and full tests are designed by IISc alumni according to the latest syllabus. Percentile, All India Rank,
interaction with IISc alumni in our online discussion forums, and more. For more details,
visit
www.gateforum.com
Think GATE Think GATE Forum
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,4f = ∑ 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 0’s and 1’s and produces an output
stream of 0’s and 1’s. Initially it replicates the input on its output until two
consecutive 0’s 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 1’s, 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 www.gateforum.com
Join discussion of this test paper at http://forum.gatementor.com
Join All India Mock GATE Classroom Test Series - 2007 conducted by GATE Forum in over 25 cities all over India. Question
Papers including section tests and full tests are designed by IISc alumni according to the latest syllabus. Percentile, All India Rank,
interaction with IISc alumni in our online discussion forums, and more. For more details,
visit
www.gateforum.com
Think GATE Think GATE Forum
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 www.gateforum.com
Join discussion of this test paper at http://forum.gatementor.com
Join All India Mock GATE Classroom Test Series - 2007 conducted by GATE Forum in over 25 cities all over India. Question
Papers including section tests and full tests are designed by IISc alumni according to the latest syllabus. Percentile, All India Rank,
interaction with IISc alumni in our online discussion forums, and more. For more details,
visit
www.gateforum.com
Think GATE Think GATE Forum
(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 www.gateforum.com
Join discussion of this test paper at http://forum.gatementor.com
Join All India Mock GATE Classroom Test Series - 2007 conducted by GATE Forum in over 25 cities all over India. Question
Papers including section tests and full tests are designed by IISc alumni according to the latest syllabus. Percentile, All India Rank,
interaction with IISc alumni in our online discussion forums, and more. For more details,
visit
www.gateforum.com
Think GATE Think GATE Forum
17. The syntax of the repeat-until statement is given by the following grammar
S repeat S1 until E
Where E stands for expressions, S and S1 stand for statement. The non-terminals
S and S1 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 www.gateforum.com
Join discussion of this test paper at http://forum.gatementor.com
Join All India Mock GATE Classroom Test Series - 2007 conducted by GATE Forum in over 25 cities all over India. Question
Papers including section tests and full tests are designed by IISc alumni according to the latest syllabus. Percentile, All India Rank,
interaction with IISc alumni in our online discussion forums, and more. For more details,
visit
www.gateforum.com
Think GATE Think GATE Forum
(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.

More Related Content

PDF
Cs 2002
PDF
Gate-Cs 1995
PDF
Cs 2003
PDF
Gate-Cs 1994
PDF
Gate-Cs 1997
PDF
Gate-Cs 1998
PDF
gate-Cs 2000
PDF
Gate-Cs 1991
Cs 2002
Gate-Cs 1995
Cs 2003
Gate-Cs 1994
Gate-Cs 1997
Gate-Cs 1998
gate-Cs 2000
Gate-Cs 1991

What's hot (20)

PDF
CAPE Computer Science Unit 1 Paper 1 - Practice Paper
PDF
B.Sc.IT: Semester - VI (May - 2018) [IDOL - Revised Course | Question Paper]
DOC
Data structures question paper anna university
PDF
GATE Computer Science Solved Paper 2004
PDF
Gate 2013 computer science and information technology previous year paper
PDF
COCOON14
PDF
B.Sc.IT: Semester - VI (April - 2015) [IDOL - Revised Course | Question Paper]
PDF
B.Sc.IT: Semester - VI (December - 2017) [IDOL - Revised Course | Question Pa...
PDF
Adaptation of Multilingual Transformer Encoder for Robust Enhanced Universal ...
PDF
Competence-Level Prediction and Resume & Job Description Matching Using Conte...
PDF
Natural Language Generation in the Wild
PDF
Graph-to-Text Generation and its Applications to Dialogue
PPTX
Isorc18 keynote
PDF
Automata And Compiler Design
DOCX
Fla 5th cse
PDF
A Concurrent Language for Argumentation: Preliminary Notes
PDF
Oops Paper
PDF
Timed Concurrent Language for Argumentation
PDF
A Concurrent Language for Argumentation
PDF
Labelled Variables in Logic Programming: A First Prototipe in tuProlog
CAPE Computer Science Unit 1 Paper 1 - Practice Paper
B.Sc.IT: Semester - VI (May - 2018) [IDOL - Revised Course | Question Paper]
Data structures question paper anna university
GATE Computer Science Solved Paper 2004
Gate 2013 computer science and information technology previous year paper
COCOON14
B.Sc.IT: Semester - VI (April - 2015) [IDOL - Revised Course | Question Paper]
B.Sc.IT: Semester - VI (December - 2017) [IDOL - Revised Course | Question Pa...
Adaptation of Multilingual Transformer Encoder for Robust Enhanced Universal ...
Competence-Level Prediction and Resume & Job Description Matching Using Conte...
Natural Language Generation in the Wild
Graph-to-Text Generation and its Applications to Dialogue
Isorc18 keynote
Automata And Compiler Design
Fla 5th cse
A Concurrent Language for Argumentation: Preliminary Notes
Oops Paper
Timed Concurrent Language for Argumentation
A Concurrent Language for Argumentation
Labelled Variables in Logic Programming: A First Prototipe in tuProlog
Ad

Viewers also liked (20)

PPTX
2014 passion party general report
PDF
Distretti 2041-20412 - Manuale Rotarct: Presidente, Vice-Presidente, Prefetto...
PDF
Black eyed-peas-gotta-feeling
PPTX
Paul's norway trip
PPTX
كل مانعرفه عن البشره
PPTX
What have you learnt about technologies from the process of constructing the ...
PDF
Gabonak 2016
PPTX
Elevator Pitch
PDF
High school-musical-all-for-one
PPTX
Буктрейлер. Ремарк. "Время жить и время умирать"
PPT
First art bike parade in Vilnius and Who did that to my bike? festival
PDF
Gate-Cs 2008
PPSX
Economic Forecasts 2014 by FKCCI - Korea's Macroeconomic Outlook and Policy D...
PDF
Dmtc mr jc
PDF
Ֆոկուսներ
PPTX
Fake book template modified.pptx
PPTX
PPTX
2013 report galeries accor
PDF
Small Team, Big UX
2014 passion party general report
Distretti 2041-20412 - Manuale Rotarct: Presidente, Vice-Presidente, Prefetto...
Black eyed-peas-gotta-feeling
Paul's norway trip
كل مانعرفه عن البشره
What have you learnt about technologies from the process of constructing the ...
Gabonak 2016
Elevator Pitch
High school-musical-all-for-one
Буктрейлер. Ремарк. "Время жить и время умирать"
First art bike parade in Vilnius and Who did that to my bike? festival
Gate-Cs 2008
Economic Forecasts 2014 by FKCCI - Korea's Macroeconomic Outlook and Policy D...
Dmtc mr jc
Ֆոկուսներ
Fake book template modified.pptx
2013 report galeries accor
Small Team, Big UX
Ad

Similar to Cs 2001 (20)

PDF
Gate-Cs 1992
PDF
Gate-Cs 1996
PDF
Gate-Cs 1999
PDF
Gate Previous Years Papers
PDF
Gate Previous Years Papers
PDF
Gate-Cs 2007
PDF
Gate Previous Years Papers It2005
PDF
Gate-Cs 2009
PDF
Gate-Cs 2010
PDF
Gate Previous Years Papers
PDF
Gate Computer Science Solved Paper 2007
PDF
CS124S5 gate exam pyq for practice for it.pdf
PDF
Cs gate-2011
PDF
Cs gate-2011
PDF
C Language MCQ Programming Theory Questions
PDF
Me 2001-unsolved
PDF
Cs 2008(1)
PDF
PGCET Computer science 2017 question paper
PDF
Midterm Exam Solutions Fall03
DOC
NET_Solved ans
Gate-Cs 1992
Gate-Cs 1996
Gate-Cs 1999
Gate Previous Years Papers
Gate Previous Years Papers
Gate-Cs 2007
Gate Previous Years Papers It2005
Gate-Cs 2009
Gate-Cs 2010
Gate Previous Years Papers
Gate Computer Science Solved Paper 2007
CS124S5 gate exam pyq for practice for it.pdf
Cs gate-2011
Cs gate-2011
C Language MCQ Programming Theory Questions
Me 2001-unsolved
Cs 2008(1)
PGCET Computer science 2017 question paper
Midterm Exam Solutions Fall03
NET_Solved ans

More from Ravi Rajput (13)

PPTX
Audio visual round fun quiz competition
PPT
Ethical hacking
PDF
Mozilla Firefox 10 Principles
PDF
Presentation over Wi-Fi technology
PDF
UTU Syllabus for CSE & IT 2nd year
PDF
Syllabus cs and_IT 2nd year UTU( Uttarakhand technical university)
PDF
Computer network unit 1 notes
PDF
Cs gate-2012
PDF
Gate-Cs 2006
PDF
Gate-Cs 1993
PDF
4 sem unix 2011
PPT
Presentation on-video-conferencing-basics4468-ravi shankar-pc
PDF
Basic html tutorial
Audio visual round fun quiz competition
Ethical hacking
Mozilla Firefox 10 Principles
Presentation over Wi-Fi technology
UTU Syllabus for CSE & IT 2nd year
Syllabus cs and_IT 2nd year UTU( Uttarakhand technical university)
Computer network unit 1 notes
Cs gate-2012
Gate-Cs 2006
Gate-Cs 1993
4 sem unix 2011
Presentation on-video-conferencing-basics4468-ravi shankar-pc
Basic html tutorial

Recently uploaded (20)

PPTX
Virtual and Augmented Reality in Current Scenario
PDF
MBA _Common_ 2nd year Syllabus _2021-22_.pdf
PPTX
Onco Emergencies - Spinal cord compression Superior vena cava syndrome Febr...
PPTX
20th Century Theater, Methods, History.pptx
PDF
LDMMIA Reiki Yoga Finals Review Spring Summer
PDF
David L Page_DCI Research Study Journey_how Methodology can inform one's prac...
PDF
IGGE1 Understanding the Self1234567891011
PPTX
TNA_Presentation-1-Final(SAVE)) (1).pptx
PPTX
Computer Architecture Input Output Memory.pptx
PDF
ChatGPT for Dummies - Pam Baker Ccesa007.pdf
PDF
Chinmaya Tiranga quiz Grand Finale.pdf
PDF
Vision Prelims GS PYQ Analysis 2011-2022 www.upscpdf.com.pdf
PDF
FORM 1 BIOLOGY MIND MAPS and their schemes
PDF
احياء السادس العلمي - الفصل الثالث (التكاثر) منهج متميزين/كلية بغداد/موهوبين
PDF
BP 704 T. NOVEL DRUG DELIVERY SYSTEMS (UNIT 1)
PDF
RTP_AR_KS1_Tutor's Guide_English [FOR REPRODUCTION].pdf
DOC
Soft-furnishing-By-Architect-A.F.M.Mohiuddin-Akhand.doc
PDF
Paper A Mock Exam 9_ Attempt review.pdf.
PDF
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
PDF
medical_surgical_nursing_10th_edition_ignatavicius_TEST_BANK_pdf.pdf
Virtual and Augmented Reality in Current Scenario
MBA _Common_ 2nd year Syllabus _2021-22_.pdf
Onco Emergencies - Spinal cord compression Superior vena cava syndrome Febr...
20th Century Theater, Methods, History.pptx
LDMMIA Reiki Yoga Finals Review Spring Summer
David L Page_DCI Research Study Journey_how Methodology can inform one's prac...
IGGE1 Understanding the Self1234567891011
TNA_Presentation-1-Final(SAVE)) (1).pptx
Computer Architecture Input Output Memory.pptx
ChatGPT for Dummies - Pam Baker Ccesa007.pdf
Chinmaya Tiranga quiz Grand Finale.pdf
Vision Prelims GS PYQ Analysis 2011-2022 www.upscpdf.com.pdf
FORM 1 BIOLOGY MIND MAPS and their schemes
احياء السادس العلمي - الفصل الثالث (التكاثر) منهج متميزين/كلية بغداد/موهوبين
BP 704 T. NOVEL DRUG DELIVERY SYSTEMS (UNIT 1)
RTP_AR_KS1_Tutor's Guide_English [FOR REPRODUCTION].pdf
Soft-furnishing-By-Architect-A.F.M.Mohiuddin-Akhand.doc
Paper A Mock Exam 9_ Attempt review.pdf.
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
medical_surgical_nursing_10th_edition_ignatavicius_TEST_BANK_pdf.pdf

Cs 2001

  • 1. GATE CS - 2001 www.gateforum.com Join discussion of this test paper at http://forum.gatementor.com Join All India Mock GATE Classroom Test Series - 2007 conducted by GATE Forum in over 25 cities all over India. Question Papers including section tests and full tests are designed by IISc alumni according to the latest syllabus. Percentile, All India Rank, interaction with IISc alumni in our online discussion forums, and more. For more details, visit www.gateforum.com Think GATE Think GATE Forum 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: (P⇒¬P)∨(¬P⇒P) 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 1n n ≥ is a regular language S2: { }0 1 0 1 and 1m 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
  • 2. GATE CS - 2001 www.gateforum.com Join discussion of this test paper at http://forum.gatementor.com Join All India Mock GATE Classroom Test Series - 2007 conducted by GATE Forum in over 25 cities all over India. Question Papers including section tests and full tests are designed by IISc alumni according to the latest syllabus. Percentile, All India Rank, interaction with IISc alumni in our online discussion forums, and more. For more details, visit www.gateforum.com Think GATE Think GATE Forum 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) N2 (b) 2N (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 program’s 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
  • 3. GATE CS - 2001 www.gateforum.com Join discussion of this test paper at http://forum.gatementor.com Join All India Mock GATE Classroom Test Series - 2007 conducted by GATE Forum in over 25 cities all over India. Question Papers including section tests and full tests are designed by IISc alumni according to the latest syllabus. Percentile, All India Rank, interaction with IISc alumni in our online discussion forums, and more. For more details, visit www.gateforum.com Think GATE Think GATE Forum 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) w x 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(n2 ) (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 (i≤n), 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
  • 4. GATE CS - 2001 www.gateforum.com Join discussion of this test paper at http://forum.gatementor.com Join All India Mock GATE Classroom Test Series - 2007 conducted by GATE Forum in over 25 cities all over India. Question Papers including section tests and full tests are designed by IISc alumni according to the latest syllabus. Percentile, All India Rank, interaction with IISc alumni in our online discussion forums, and more. For more details, visit www.gateforum.com Think GATE Think GATE Forum 1.16 Let ( ) ( ) ( )102 log and logf 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 r1, r2, …. rn 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
  • 5. GATE CS - 2001 www.gateforum.com Join discussion of this test paper at http://forum.gatementor.com Join All India Mock GATE Classroom Test Series - 2007 conducted by GATE Forum in over 25 cities all over India. Question Papers including section tests and full tests are designed by IISc alumni according to the latest syllabus. Percentile, All India Rank, interaction with IISc alumni in our online discussion forums, and more. For more details, visit www.gateforum.com Think GATE Think GATE Forum 1.23 Consider a schema R(A,B,C,D) and functional dependencies A B and C D. Then the decomposition of R into R1 (AB) and R2(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∩(B∪C) 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
  • 6. GATE CS - 2001 www.gateforum.com Join discussion of this test paper at http://forum.gatementor.com Join All India Mock GATE Classroom Test Series - 2007 conducted by GATE Forum in over 25 cities all over India. Question Papers including section tests and full tests are designed by IISc alumni according to the latest syllabus. Percentile, All India Rank, interaction with IISc alumni in our online discussion forums, and more. For more details, visit www.gateforum.com Think GATE Think GATE Forum 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(E∪F)=f(E) ∪f(F) S2:f(E∩F)=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 a’s divisible by 6 and number of b’s 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 wR R L ww w a b w= ∈ { }2 3 0 i is an integeri L = { }2 3 0 i is an integeri 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
  • 7. GATE CS - 2001 www.gateforum.com Join discussion of this test paper at http://forum.gatementor.com Join All India Mock GATE Classroom Test Series - 2007 conducted by GATE Forum in over 25 cities all over India. Question Papers including section tests and full tests are designed by IISc alumni according to the latest syllabus. Percentile, All India Rank, interaction with IISc alumni in our online discussion forums, and more. For more details, visit www.gateforum.com Think GATE Think GATE Forum 2.8 Consider the following circuit with initial state Q0 = Q1 = 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 C≥40 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 0Q C X
  • 8. GATE CS - 2001 www.gateforum.com Join discussion of this test paper at http://forum.gatementor.com Join All India Mock GATE Classroom Test Series - 2007 conducted by GATE Forum in over 25 cities all over India. Question Papers including section tests and full tests are designed by IISc alumni according to the latest syllabus. Percentile, All India Rank, interaction with IISc alumni in our online discussion forums, and more. For more details, visit www.gateforum.com Think GATE Think GATE Forum 2.10 The 2’s 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 2f x x′= + (b) 1 2 1 2f x x x x′ ′= + (c) 1 2 1 2f x x x x′ ′= + (d) 1 2f x x ′= + 2.12 Consider the circuit given below with initial state Q0 =1, Q1 = Q2 = 0. The state of the circuit is given by the value 2 1 04 2Q 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
  • 9. GATE CS - 2001 www.gateforum.com Join discussion of this test paper at http://forum.gatementor.com Join All India Mock GATE Classroom Test Series - 2007 conducted by GATE Forum in over 25 cities all over India. Question Papers including section tests and full tests are designed by IISc alumni according to the latest syllabus. Percentile, All India Rank, interaction with IISc alumni in our online discussion forums, and more. For more details, visit www.gateforum.com Think GATE Think GATE Forum 2.13 Consider the following data path of a simple non-pilelined CPU. The registers A, B, A1, A2, 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, , nV v v v= K of n vertices? (a) ( )1 2 n n − (b) 2n (c) n! (d) ( )1 22 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 MDRSPdcr
  • 10. GATE CS - 2001 www.gateforum.com Join discussion of this test paper at http://forum.gatementor.com Join All India Mock GATE Classroom Test Series - 2007 conducted by GATE Forum in over 25 cities all over India. Question Papers including section tests and full tests are designed by IISc alumni according to the latest syllabus. Percentile, All India Rank, interaction with IISc alumni in our online discussion forums, and more. For more details, visit www.gateforum.com Think GATE Think GATE Forum 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; }
  • 11. GATE CS - 2001 www.gateforum.com Join discussion of this test paper at http://forum.gatementor.com Join All India Mock GATE Classroom Test Series - 2007 conducted by GATE Forum in over 25 cities all over India. Question Papers including section tests and full tests are designed by IISc alumni according to the latest syllabus. Percentile, All India Rank, interaction with IISc alumni in our online discussion forums, and more. For more details, visit www.gateforum.com Think GATE Think GATE Forum 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
  • 12. GATE CS - 2001 www.gateforum.com Join discussion of this test paper at http://forum.gatementor.com Join All India Mock GATE Classroom Test Series - 2007 conducted by GATE Forum in over 25 cities all over India. Question Papers including section tests and full tests are designed by IISc alumni according to the latest syllabus. Percentile, All India Rank, interaction with IISc alumni in our online discussion forums, and more. For more details, visit www.gateforum.com Think GATE Think GATE Forum 2.22 Consider Peterson’s 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 2t 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) ( ){ }1t t R¬ ∈ (d) ( ) ( ){ }1 2t 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 y≥x. 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
  • 13. GATE CS - 2001 www.gateforum.com Join discussion of this test paper at http://forum.gatementor.com Join All India Mock GATE Classroom Test Series - 2007 conducted by GATE Forum in over 25 cities all over India. Question Papers including section tests and full tests are designed by IISc alumni according to the latest syllabus. Percentile, All India Rank, interaction with IISc alumni in our online discussion forums, and more. For more details, visit www.gateforum.com Think GATE Think GATE Forum (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: N×N 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 DFA’s for the following languages: (a) { }{ }, *, w has baab as a subsringL w w a b= ∈ (b) { }{ }, *, w has an odd number of a's and an odd nuber of b'sL w w a b= ∈ 6. Give a deterministic PDA for the language { }2 1n 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.
  • 14. GATE CS - 2001 www.gateforum.com Join discussion of this test paper at http://forum.gatementor.com Join All India Mock GATE Classroom Test Series - 2007 conducted by GATE Forum in over 25 cities all over India. Question Papers including section tests and full tests are designed by IISc alumni according to the latest syllabus. Percentile, All India Rank, interaction with IISc alumni in our online discussion forums, and more. For more details, visit www.gateforum.com Think GATE Think GATE Forum 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,4f = ∑ 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 0’s and 1’s and produces an output stream of 0’s and 1’s. Initially it replicates the input on its output until two consecutive 0’s 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 1’s, 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
  • 15. GATE CS - 2001 www.gateforum.com Join discussion of this test paper at http://forum.gatementor.com Join All India Mock GATE Classroom Test Series - 2007 conducted by GATE Forum in over 25 cities all over India. Question Papers including section tests and full tests are designed by IISc alumni according to the latest syllabus. Percentile, All India Rank, interaction with IISc alumni in our online discussion forums, and more. For more details, visit www.gateforum.com Think GATE Think GATE Forum 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.
  • 16. GATE CS - 2001 www.gateforum.com Join discussion of this test paper at http://forum.gatementor.com Join All India Mock GATE Classroom Test Series - 2007 conducted by GATE Forum in over 25 cities all over India. Question Papers including section tests and full tests are designed by IISc alumni according to the latest syllabus. Percentile, All India Rank, interaction with IISc alumni in our online discussion forums, and more. For more details, visit www.gateforum.com Think GATE Think GATE Forum (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.
  • 17. GATE CS - 2001 www.gateforum.com Join discussion of this test paper at http://forum.gatementor.com Join All India Mock GATE Classroom Test Series - 2007 conducted by GATE Forum in over 25 cities all over India. Question Papers including section tests and full tests are designed by IISc alumni according to the latest syllabus. Percentile, All India Rank, interaction with IISc alumni in our online discussion forums, and more. For more details, visit www.gateforum.com Think GATE Think GATE Forum 17. The syntax of the repeat-until statement is given by the following grammar S repeat S1 until E Where E stands for expressions, S and S1 stand for statement. The non-terminals S and S1 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;
  • 18. GATE CS - 2001 www.gateforum.com Join discussion of this test paper at http://forum.gatementor.com Join All India Mock GATE Classroom Test Series - 2007 conducted by GATE Forum in over 25 cities all over India. Question Papers including section tests and full tests are designed by IISc alumni according to the latest syllabus. Percentile, All India Rank, interaction with IISc alumni in our online discussion forums, and more. For more details, visit www.gateforum.com Think GATE Think GATE Forum (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.