0% found this document useful (0 votes)
61 views4 pages

WWW - Solutionsadda.in: Examination Department of Computer Science and Engineering

(1) A non-preemptive CPU scheduler cannot be called when I/O completes for a process, as the process must continue running until it voluntarily relinquishes the CPU or blocks on another I/O request. (2) The argument that paging cannot be implemented because accessing the page table requires its own translation has a flaw - the page table entries for the kernel's address space are permanently resident in memory, allowing translation of any address. (3) A context switch has an effect on the TLB - it must be flushed on a context switch to avoid mapping the virtual addresses of one process to the physical pages of another.

Uploaded by

SupravatAppa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
61 views4 pages

WWW - Solutionsadda.in: Examination Department of Computer Science and Engineering

(1) A non-preemptive CPU scheduler cannot be called when I/O completes for a process, as the process must continue running until it voluntarily relinquishes the CPU or blocks on another I/O request. (2) The argument that paging cannot be implemented because accessing the page table requires its own translation has a flaw - the page table entries for the kernel's address space are permanently resident in memory, allowing translation of any address. (3) A context switch has an effect on the TLB - it must be flushed on a context switch to avoid mapping the virtual addresses of one process to the physical pages of another.

Uploaded by

SupravatAppa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

____ .

-4

PhD Comprehensive Examination


Department of Computer Science and Engineering
Date: 14-March-20 13 Time: 4 Hours Maximum Marks: 100

[Answer any five questions from Group A. and any five questions from Groups Band C combined.]

Group A

A.I Write only the answers of the following questions. No need to write any explanation.

(a) Write the asymptotic upper bound ofT(n) = T(3n/1O) + T(7n/10) + IOn. (2)
(b) The array representing a rnax-heap is 20 12 10 8 4 7 q ~ ~ 3
Write the value of the element stored in the parent node of the node containing the smallest
element, i.e., 'L.· (2)
(c) Given an unordered list L of ~ers, what is a tight lower bound on the worst case time
complexity to find afthe pair of elements from L, which have the minimum difference amon&.?l!
possible pair's in L? (2)
-----
(d) What is a tight lower bound on the average-case time complexity for successful search in a
w

complete binary tree (which is not necessarily a binary search tree). (2)
w

(e) An undirected graph G containing n nodes and O(n log n) edges is represented by an adjacency
matrix. Write the time complexity that will be reqUire"dby an optimal algorithm to prepare the
w

adjacency list of G from its adjacency matrix. (2)


.s

G(V, E) is an undirected, unweighted graph, represented by an adjacency list. It is known that G is a


forest comprising of some trees; Suggest anefficient algorithm to find a set of edges F C (V x V) - E
ol

so that G'(V, E U F) is a single tree (i.e., find a set of edges from (V x V) - E to connect all the
trees into a single tree). Explain its time complexity. . (7 + 3 = 10)
----- -- --.-----
ut

A.3 T is a height-balanced binary search tree containing n distinct integers. Suggest an algorithm to report
/

the elements of T lying in the interval [a, b]. Assume that n > > b - a.
io

Explain its tim~ complexity as a functio'n~f"fL, a, b. ,~it (7 + 3 = 10)


ns

A.4 Write a C function int SubPal(char *S, int *start, int *len) that takes a null-terminated character
string S as a parameter, and checks if any substring of S is palindrome (a substring is any set of a
consecutive characters in the string). The function returns 0 if no such substrings are found. It returns
ad

I if at least one such substring exists, in which case the starting index of the substring is returned in
sta.rt and the length of the substring is returned in len. If more than one such palindrome substrings
da

exists, the starting index and length of any one 'Such substring is returned. j
For example, if S ='" character", then the function returns 1 and sets «start = 2 and »len = 3
for the palindrome substring" ora", However, if S = "palindrome", the function returns 0, and the
.

values in «start and «len are irrelevent (can be anything).


in

(10)
J
A.S You are to implement a hash tab~e to store at most 12"o,,£,integers. The hash fuction used for any keX k
is k%lOOO. The collision resolution scheme used is open addressing . c-:
--::==;:'9 -
(a) Define a data type ,_...
HASHTABL~ to represent. . ahash. table. to store at most 1000 integers.
(b) Write a C function int Illsert(HASHTABLE H, int k) that inserts a key J5. into a hashtable H.
The function returns 1 if the insert i~ successful~ full. _-----.

, \ _ p~ge 1 of 5 _ -7\~·I.~"f-.--T':"- L_.~J


'~f'---~':
\....... \
.,. - \ ',.,k \
\
-:\.\ !.\..
:.-> "'.\
-)\ ,---. :_.---' .
;'--.~-., ) • __
.- I

\ \

~ .,,---
, v
\,~ ,

'. ~
~/', \
r:.--.~ /
'"

------------------------ __
--_----1
/ C.3 (a) Can a non-preemptive CPU scheduler be called when some I/O that a process is waiting for
completes? Justify your answer clearly.
(b) "The page table of a process is kept in main memory. To access anything in main memory
in a system with logical addressing, the translation of a logical address to a physical address
is needed. Therefore, to access the page table itself, a logical address must be coverted to a
physical address, which cannot be done without accessing the page table. Hence, paging cannot
be implemented" - where is the flaw in this argument? Justify your answer clearly.
(c) Does a context switch have any effect on the TLB? Justify your answer.
(3 + 4 + 4)

C.4 :f Implement the four Boolean functions listed using three half-adder circuits:

D = AEBBEBC
E A'BC+AB'C
F = ABC' + (A' + B')C \" 1 I 1\
,L-
G = ABC I
\
-
~DeSign a sequential circuit with J K fiip-~ps to satisfy the following st~te equations:
w

A(t+l) = A'B'CD+ A'B'C+ ACD+ AC'D' ..,?' jf.. .


w

\ ""0'0\\ B(t+l) = A'C+CD~+A'BC' <, \. \'~

= 10)
w

(5 + 5

C.5
.s

(a) You are an engineer at Outtel, a start-up company aspiring to compete with Intel via its new
processor technology that outperforms the latest Intel processor by a factor of 2.5 on floating
ol

point instructions. To achieve this level 'of ffoating 29int erforrnance, the design team had to
make compromises that led to a' '-()% 'avera e incre . xecution times- ofall other instruc-
ut

tions. You are in charge of chosing benchmarks that wouldshowcase Outtel's performance edge, -
(i) What is the minimum required fraction f of time spent on floating point instructions in a
io

program on the Intel processor to showa-;peed up of 2 for Outtel?v-


(i) If on the Intel processor, execution time of a floating point instruction is on an average 3
ns

times as long as other instructions, what does the fraction in your answer to part (i) mean in
terms of the Instruction mix of the benchmark? .;'
12
ad

Suppose a ~ cache has set-associative address mapping. There are sets, each containing
four cache blocks or lines, The memory address size is 32 bits, and the smallest addressable unit
is the byte. Label the components of the 32-bit address for accessing the cache memory.
da

.• (5 + 5 = 10)
~cache memories refer to a faster intermediate form of memory within a larger memory hierarchy. The
.

following sequence of numbers represent memory addresses in a M-:word main mempry: o, I, 2, 3,


in

4, IS, 14, 13, 14; n. 10. 9~ O,h,\2, 3, 4, ~, 28, 32,: IS, 14, 13, 12,0, 1,2, 3:..•.Classify each of the.
accesses as a cache .hit, com ~\sory miss, capacit~ miss, or conflict ~ss, given the following cache

p~:m;::: mapped,4-wordlin;s, 4;lill' capacity. ~ ~1)'- ~~_


[f'- -:-'
(ii) Two-way set associative, 4-word lines, 2-set capacity, LRU replacement. ..L-'l..•• ~.-
"\,.. ~ -J.... I

v> ~~ 1-1- ..•....


1,; b 'i ~. ~'-. (5 + 5 = 10) ~
~ to
\ I\)
'<l \ -)") , '\. .~' '1.. '£ ~ ~,-,:, 1" )..t..-l 'y-\ Y· -c· ~

~'~ 10 0-1 l£- () -- /. i\ ~ W;:1.- t.\


0'0 \ /.- "\- Page 5 of 5 -'
\'.\. L... •1- t, t "l-- -...-,.

\\ 'l> ;:sY-:
/
1 GroupB
. ,/ /' / r ,.- ~L....\O
• B.1 (a) Prove by contrapostion : If n is a positive integer with n2 > 100, then n > 10. L '

(b) Prove by induction: Every integer greater than 1 is a product of prime numbers. / "f

....., '\.. 1.1.., v: V" (5+5=10)


,., • \ ry • 1--
I.., (... '-"<i I t-

B.2 (a) Show that composition of functions is associative."" ~, ~. 1... '\ q,


(b) Prove that among any five points in the plane with integer coordinates, there are at least two
points such that the center of th~ line segment that connects them also has integer coordinates.
(5 + 5 = 10)
B.3 (a) Show the recurrence relation for computing M(n), where ,M(n) is the number of moves needed
to move n disks from peg i to peg j in the Tower of Hanoi 'problem.
r

(b) A test for a disease that affects 2j100fthe population is~effectiveon people with the disease
(that is, it says they have it with probability 0.99). The test gives a false reading (saying that a
person who does not have the disease is affected with it) for ~of the population without the
disease. What is the probability that someone selected' at random and given a test for the disease
will have a positive test~ What is the probability that someone who has positive test results in
w

fact has the disease? .


(4+6=10)
w

B.4 (a) Let L1 be the language over {QJl..consisting of all strings that have a Un the third symbol
w

from the end (e.g., the string 0100 is in L1). Draw a Deterministic Finite State Automata (DFA)
containing 'minimum number of states that recognizes L1•
,
.s

(b) For a DFA A recognizing language L, interchanging final and non-final states gives an automaton
that recognizes t, the complement of L. Is this also true for. Non-deterministic Finite State
ol

Automaton (NFA)? If your answer is yes, give a proof, if no, give a counterexample.
ut

(c) Consider the following language L2 defined over the alphabet {O, I}.
L2 = The set of all strings s such that the number of Os and number of Is in s differ by
io

0--':.> f'\.J..... -.~


no more th~. D t> -
Prove that L2 iyegular . ./ +>
ns

(4+2+4)

(a) Carefully state the Pumping Lemma for regular languages.


ad

(b) Use the pumping lemma to prove that the following language L3 over the alphabet {O, I} is not
regular.
da

(3 + 7 = 10)
. in

(a) Give a context free grammar for the following language L4. The alphabet E is {O, 1, #}.
L4 = { w : w starts and ends with the same symbol, the length is odd, and the middle symbol is
#}. - ,
'-'
Draw the parse tree of the following string with the above grammar:
"'0101#1110 '1
QDrove that if L is context free, then L* must be con~xt free.
V .,~ 'oJ. (5 + 5 = 10)
\.,.\.

- Page 3 of 5 -

\
C; ---) o ~ 0 1) S (0 ~ o \ ,~ II
\
,\ \ \iO 0
'!I "
~\}V
",00 Q
\\-~
. '
v~ <;, ) \ ~ 0
if" J.

11~ols~ '1",:'
IY »> • '" \ (\
,,,\,
1- )
~->01\\
~ ~ __~L~------------_
Group C

c.r (a) List clearly how a running process can be preempted and a new process run on a system using
round-robin scheduling.
(b) An OS gives two system calls sleepO and wakeup(p). The sleepO call just puts the calling
process (say x) to sleep until it is woken up by a wakeup(x) call made by some other process.
The wakeup(x) call wakes up the specified process x if it is sleeping; if x is not sleeping when
the wakeup(x) call is made, the call has no further effect. The following C-like pseudo-code
is proposed for a naive solution to the Producer-Consumer Problem on this as:
#define N 100 II number of slots in the buffer
int count = 0; II number of items currently in the buffer

void producer (void)


{
int item;
w

while (TRUE) (
item = produce_item();
w

if (count == N) sleep(); II if buffer is full, sleep unt~l woken up


insert_item(item);
w

count++; II increment number of items in buffer


if (count ==
1) wakeup (consumer) ; II was buffer empty?
.s
ol

void consumer (voiti)


ut

int item;
while (TRUE) (
io

if (!count) sleep(); II if buffer is empty. sleep


item = remove_item();
ns

count--;
if (count == N - 1) wakeup (producer) ; II was buffer full?
consume_item(item) ;
ad

Unfortunately, this solution runs into tr.•ouble sometimes, with both the producer and the con-
da

sumer going to sleep forever. Explain how this might happen in brief, clearly stating the possible
sequence of operations that can cause this. Assume that no atomic operations are available.
.

(5 + 5)
in

Suppose we have a program that consists of ~'lt £ages (numbered 1 through 8), and we have
" (a) four page frames of physical memory for it. Find the minimum number of page faults possible

,.
for the following page reference string: -

1 2 3 2 563
..•.•. ,
4 6 3 7 3 1 5 3 6 3 4 2 4 3 4 5 1
(b) Estimate the number of page-faults for the following page reference string when the FIFO page-
replacement scheme is applied to it, for two different number of available frames - 3 frames and
4 frames:

1 2 3· 4 1 2 5 1 2 3 4 5

(5 + 5)

- Page 4 of 5 -

~~------------~--~--~~----

You might also like