Section (Iv) : Computer Science
Section (Iv) : Computer Science
11
3. Let be an matrix of integers, where for some integer
. Consider a program that traverses the matrix following a -
like traversal, and prints the elements of the matrix in the order of
traversal, as shown in the figures below.
1 2 4
3
1 2
5 6 7 8
9 10 12
11
3 4
13 15 16
14
[14]
4. Consider a jungle, where tigers and elephants live. The only source
of water in the forest is a lake, situated in the middle of the forest.
Tigers and elephants drink water from the lake. Suppose we model
each animal by a process. The code outlines for tiger processes and
elephant processes are given below. Using semaphores to synchronize
their operation, fill in the outlines so that a tiger process and an ele-
phant process never execute simultaneously.
12
Your solution should, however, permit multiple animals of the same
kind to drink simultaneously. You may use as many semaphores as
necessary.
[14]
5. (a) Consider the transactions and where is nested within .
If the underlying DBMS follows an immediate update policy for
a log-maintenance system, suggest what actions would be taken
by the recovery manager when a crash occurs in each of the four
different positions shown below.
: Read(A)
Write(A)
Position 1
: Read(B)
Write(B)
Position 2
Commit( )
Position 3
Commit( )
Position 4
(b) For a relation , the following functional de-
pendencies are given:
.
Decompose into a set of normalized relations so that the new
set of relations is free from partial and transitive dependencies.
[8+6=14]
6. (a) Let and let
and has the same number of occurrences of
the substrings 01 and 10 .
Thus, (it contains one occurrence each of 10 and 01),
but (it contains two occurrences of 10 and one occur-
rence of 01). Show that is a regular language.
13
(b) A grammar is said to be ambiguous if for some string in
the language generated by , there exists two or more different
parse trees. Show that the following grammar is ambiguous:
14
(b) Consider a unifunction pipeline consisting of five stages, , ,
, and . The required function is evaluated in nine clock
cycles following the reservation table as given below.
Clock
cycle 0 1 2 3 4 5 6 7 8
X X
X X X
X
X X
X X
15