Uploaded by Harsh Choudhary

sem 3 end sems

advertisement
..
ludian Institu te of '1-,cchHology Goa
l~J~ 2:l2 Digit.al Circuits and Lah / CS 210 l)1·g1·t,,·ll S
, ys t,e m s J) cs ·1g 11
I11st n1 <"1 or: Nn 11d nk 11111;ir NH111h;it I,
en d- Sr'1/l('S/ ('r
f,,'_/'(/ 'l/l.i 7//I I irm
finw : J ll unrs
1\ l;1xi11111111 1\ 1,,rks:
:m
J,,.,t111d i011s:
i.
ii .
111.
I\'.
"·
Do not writ<' ,rnyt hi11g 011 your quest.ion p a per except for yom 11n111e a nd roll 1111111IH'r.
J1C'ad the q11C'st.in11s ca.rC'folly before star ting to am,wcr them .
llsC' pa pC'r j11diciom;ly. \\'rite only Lhe essent ia l st.cps. However , a nswers wit ho1 1t th<' ess<'11f ial
st cps will b e awarded zero marks.
A11y clarificat.ious rcgardiug t.hc qucst.ious will 110L l>c c11Lcr taiuc<l. J\ssurne suit.able <lala. if
missing . and st.ate them clearly in your a nswer sheets .
l\o written/ printed /xerox materials a nd electronic gadgets a re allowe<l in t,hc exam hall.
l. A Boolean function is given by f = a.c + a.'b + cd'. (a) Construct a truth ta ble corresponding to this
5 J\la rk~
function . (b) Represent f in canonical SOP a nd POS formats .
2. A multiplexer circuit is shown below. (a) Write down t he Boolean exp ressions of the variables a, b. c.
and f in terms of x, y , a nd z. (b) Draw a circui t which has the same fun ctionali ty usi11g KOT /lll(I
5 Mark.,
two input AND and OR gates.
X
y
z
C
n----1
f
1
0
3. A Bool(•au fuuction is giw'11 by f(1·, y , z) = L,,,( 1, 3, G, 7) . (a) Fi11d I Ill' 111i11i11111111 mst POS t':-.pn•:-:--i,m
of tJw fuudion usiug tlw Karnaugli u1ap JJH ' f ltod and lis t down I Ii<' t'ssv11I inl a nd 11011-t•s:--1'111 ial pt i1111'
impli('aJJtS. (b) l111plt•JJJ<'IJt t)ie 1lli1Jillllllll C'0St f1111d i<HI 11s i11g J\'OT and I \\'O i1 1p11l t\ \' I) a'.1d on .~, lt1 •-.
(c·) Jf t)ie rniuiurn111 c-01,t fu11ctio11 is i111pl< •11w11t<·d 11si 11g Ci\ lOS gait's, l1mv 111a11r tr,U1:--1-.t1>1 :-i \\di 111'
1)wu.'! (d) \\'iJJ tlw 111iui11m111 ('o,.,t i111pli •11w11tat io11 s l1mv any li11ii11g ha1.a 1d ? If y1•s, 11;u111• f h, • h,l.'.,1.t
i .\/,11J.,
a.ud modify the drn1it s u('h that tJw C'in-11it is hazard fr1•1 •.
biwuy n,d1•s if it s i11p11l II i:-i O a11d 1·<J1111t s d,1\\ ll l\\1 ► l,11 l:1.1, 111, !1 • 1I
,, 1,., J. ( 11 ) )haw a hlal1• dia1•,1m11 fur tlw FS.\1 . (I,) ('1111:-.11111 t a :-t.Lt1• _1.d ,l, • .u,d ,l -.1.11,· -''"' ·111 ,I
t;il,l•· t1JJJ• •i--J>•iwliuJ~ to tlw i,,lal<• diagrn111 . ((') Fiwl 1111l tlw <·:-.1111•:---.i111r-, 11l _1_lr1• 111•,1 -, (,LI,' \.L11.d,I," 111
1
ti-nw, "f tlw ,,..~•·i,t ,.,t a li • ,·.111,1l,l1·!', awl tlw 11111111 (d ) l111pl1•1111·11t 1111· l·S\I 11-, 11 1·•, I) tlq tl,,p, .111,I
1
(t-) 'J'i.1w,fu1111 tlw lu~•,JI' 1 Ill 1111 ..,11111 111.1I II\ ll q,-ll"t'~ .,,,· 11-, ,I
,t IJIIIIIIIJIJJJI IJlllJJIJl'J c,f J, 11 ~w 1:,1t1 •r,
j ,\ /o1d'
11,..,ti-,ad uf]) fl1J, l111p--.
4. Au FS~f c·ouut i; up
(W()• l,it
5. TIH' fol!m,·ing logic C'irc11it is i11i t.ializc•d liy n...,srr1i11g th<' TISTN sigrlll l for 0 1H' cloc k cy r le·. (a) /Jr;1w
)
a ti 111i11g diagram of Qo, Q, , and Q 2 for 1lr r fin,!. [j C'loc-k cyclr•s c1 f1<•1 RSTN ,~ dC'-il.'>!-)<•J11'd (Ii
Draw a state diagram corresponding to tl1r circuit . (r) JuC'n lify tlr <' 1i111i11g :im, a11d 1lH· c1ilic;i/
path of tlir circui t . (c.1 ) Find out th e· 111axi1111m1 fr< ·q11<' lH',Y of CJJJ('rn tio11 of lh<' <'irrnil if: for llH•
fi ip-fl ops, i.-u = l.Ous, f11 = 0.4 ns, and t,,Q = 1.4 - 2.0ns, a nd for !Irr gnl<'s, f p,,\Of' = 1.6 - 2.0w,,
z dock, clrsig11 anofh<'r c-irrnit 1l1r11
t ,1.A .'\ "D = 4.0 - 4.4 ns, and t,,.xon = 4.5 - 5.0 ns. ~ Gi vr11 a J GJJ
5 Mm/, .c;
g<.'ncratcs a d ock with t he maximum frrqnr ncy of operation of U1c shown circ11 it.
T Qi---- +---Qo
TFFO
TFF I
CLK
Q,
T Q Q2
TFF2
- - + - -- - ~
0------+-------RSTNo ---..___ _ _ _ _ _....__ _ _ _ ___,
this
6. An FSI\1 represent ed by t he sta te diagram given below has an input a a nd an output y . (a) Docs
1
state diagram r epresent a completely specified FSl\I? \i\ hy? (b) Draw the minimized sta te diagram
.
using t he partit ion minimiza tion procedure. (c) Ident ify the type of t he FSI\I (Moore or l\ Iealy)
5 Marks
Justify your answer. (d) Transform t he minimize d state diagram to t he other type.
0/ 0
1/0
RSTN
0/ 0
0/ 0
·11111<1) ·" 1-:MES'I ER 202 2 • 20 2.l
('O( l R.'-1•: : H :11:t Slrndun·'i & /\lg orilhrn -. (CS 220 )
[: f'\ J..
~ t M<"J i l.,
H»nprwwn.••»'-4' Examination
Max imum Marks:90 (4 5'#)
llal<':0 1/12/22
D U RAT ION : I 80M inutc,;
Cl OS ED BOOK
General lm.truc1ions/Ddini1io11s
• 11 is always ,good 10 construct an example satisfying the constrain ts in the questi on
lo begin with.
• Height of a binary tree is the number of nodes in the longest path from root to
any leaf.
• Whenever you are being asked for an asymptotic upper bound, use Big-0 notation for the same.
I. Write down a one line C/C++ statement for each of the following:
(a) Declare an integer variable named x.
(b) Declare a variable y which is capable
of holding the address of x .
(c) Declare a variable z which can hold a string containing at mos t 50 characters.
W
Read the value of the integer variable x from the terminal.
(e) Assuming y does have the address of x , print the value in x by using y, bu t not x.
[S x l ~ la rks]
2. Given that a binary tree T has height h:
(a) What is the maximum number of nodes T can have?
(b) What is the minimum number of nodes T can have?
(c) Give a 0(2 1') aJgorilhm to search for an element in T .
Jui.tfy your answers.
3. Suppo,-c that you are given a i.ingly Hnkt-d lht " 'ilh dio,tim·t iuh'gt•rs
f 2+1 +J ~la r k~J
J"l
tx.'ld \'- .
do11 · 1 have aLu•v; tn ihe
11ie I., o,/ f'l ' 111 1n pt•1111, I n the fir,1 node. Unrort un.itcly, we
Thi <, fon c11on take, the
.
JJ)
m
,
Bigs(I
count
n
,f.1fr1 fu.-1.f. \\"h,11 '"c have i), a runctio
return -, th f' num/,,, r
ction
fun
The
ad,Jrr ,,. ft mp, (l( a no<lc in a linkc<l li).l as input.
For
,f nodrs "11h 11.cy value grcale r than that of f r m p among all nodes followin g it. cti on
igs(), the fun
namp lc. if we pass the pointe r lo 25 as input to the fun ction countB
For a pointe r to 45,
rclums 1. as there are two values greate r than 25 fo llowin g it.
ure isSort ed(tcm p}
the return value will be O as 19 is less than 45. Design a proced
1 if the list is sorted in
that takes the head pointe r of a linked list as input and returns
to the data field and
ascend ing order and O otherw ise. Note that we don't have access
access to the next
the only handle availa ble is the function count Bigs() . You do have
ure in brief.
field to move around the list. Argue the correc tness of your proced
[7 Marks ]
n respectively.
4. Gi\·en two sorted intege r array s A[ J and B[ Jof length m and
arrays to one sorted
(a) \\'rite an O(m + n) proced ure that would merge these two
array C[ ].
ions perfon ned by
(b) Give an approp riate count of the numbe r of primit ive operat
each step in your proced ure and hence justify the runnin g time.
[5+3 Marks ]
5. Answ er the follow ing questi ons on max-h eaps:
(a) Draw a max-h eap contai ning IO values.
rd
nt in the max-heap.
(b) Desig n a 0(1) algori thm that determines the 3 largest eleme
h
th
el ement .mt e
a max-h eap and a value k, can we compu te the k largest
(c) Given
max-h eap in 0(2k) time? Justify.
[2+3+3 Marks ]
6. Design each of the follow ing C/C ++fun ction s:
size n as input and
(a) float Average(int ArrO, int n) : Takes the array Arr □ of
outpu ts the averag e of values in the array.
outputs the num(b) int Dup(c har Arr[J,char c) : Takes the string ArrOas input and
ber of occurr ences of charac ter c in ArrQ.
[4+4 Marks ]
7
vis ited assumi ng:
• List the vertices in the follow ing graph in the order they being
(.1)
(h)
a IWS (Depth firs! Srarch) ~tarting from \ 0.
a BFS (Bread th firs! Search) starting fro m \c1•
[4+4 Marks l
say rool I and
8. Suppose that you arc given rool poi nters of two bina ry search trees,
trees. In addition ,
roof 2, Further, it is given that all the key values arc distinct in bolh the
first tree.
rhe largesr elemen t in the second tree is less than the smalles t elemen t in the
hav(a) Draw a couple of sample binary search trees satisfyi ng the above constraints,
ing at least 6 nodes.
returns the
~ Device a procedure Merge(root 1 , root2 ) , that merges both the trees and
(h 1 , h2)),
CJ(max
time
in
root pointer of the combined tree. The procedure should run
where h 1 and h2 are the heights of the respective trees.
m
(c) Suppose that you are given that h2 is less than h 1 • Can we have an CJ(h2 ) algorith
to merge both the trees? Justify.
[3+4+2 Marks]
using the
9. Consid er an array A[O . .. 6]= 40, 50, 70, 22, 34, 45, 60 which is to be sorted
ort() and
Quick Sort Algorithm. Assum e you are provided with the following QuickS
The
Place Pivot() proced ures which sorts a given array based on Quick Sort Algori thm.
function swap() exchan ges the values of the input variables.
void Quick Sort( int A[], int begin , int end){
if ( begin <end)
{
int pi vot=P laceP i vot (A, begin , end);
Quick Sort (A, begin , pivot -1 );
Quick Sort (A, pivot + 1, end) ;
int Place Pivot ( int Inpt [], int low , int hi g h ){
for(in l k= low;k <= hi g h;k ++ )
{
",Inp t[k]) ;
printf ("%d
}
int x=lnp t[Jow ] ;
int i = low+J ;
int j = high;
while (j >= i)
f
i f ( In pt r i ] <= X)
(i ++; }
if ( In pl l j J>= x )
(j --; }
3
)& (j >i ))
if (( Jnp t [ i ] >x) &( Inp t [j ]<x
{
swa p ( In p t [ i ] , In pt [ j ]) ;
i ++ ;j -- ;
swa p ( In pt [ j ] , In pt [ low J);
pri ntf (" %d \n " , j ) ;
ret urn J;
ve given
n call Qu ickSort(ALJ, 0, 6) for the abo
ctio
fun
the
of
ut
outp
the
ine
erm
Det
(a)
array ALJ .
, 1, 2} =
ents bein g the same. (for example, A[O
(b) Let the array AOhas all the n clem
ort()
time complexity of the given Qu ickS
22, 22, 22 for n=3). What will be the
proced ure? Justify your answer.
algorithm for the given Place Pivot()
[6+4 Ma rks]
with dis tinct cleend pointers of a dou bly link ed list
10. Suppose that we have both the
ments as shown below.
tail) that
design a proc edure PlacePivot(head,
The list contains n nodes. We need to
works very
of the doubly linked list as input and
takes two end pointers hea d and tail
in
procedure places the firs t node in the list
The
9.
n
stio
Que
in
one
the
to
it
spir
in
similar
position are
ry node valu e precedin g the new pivot
an appropriate position such that eve
ced ure
For example once the PlacePivot () pro
lesser and those following are greater.
edes 25, and 45 succeeds 25.
operates on the above list, 19 and 15 prec
your prost the pointer manipulations made by
enli
e,
ctur
stru
e
nod
ve
abo
the
ing
um
Ass
sume any
, the procedures aren 't supposed to con
cedure in both the following. Further
number of temporary variables.
additional space other than a constant
that it runs in 0 (n) time.
(a) Design PlacePivot(start,end) such
rithm that
ure to have a variant of quick sort algo
(b) Can we extend the above proced
er.
n) time on average ? Justify your answ
works on doubly linked lists in O(n log
[20 Ma rks]
********END********
4
Fi11 :d l·>u 1111
n11,I S 11i1i ... 1i, 'i I,, ,. C:S
f
S,1 1,,111111 I l'I
>r
l
( 11111·:-- " l11 :-- lnwl1 1r .
I I,I
' ,
I .
.I '
,
(
l >1 vyH f\ 11 • 111 11 V
t'; u · 111,g A :--:-- i:--1 ;1111,
, , 111f.11r1
( ·s. ·,-··w •/ ( ·s,
,
·
. ,f,t ; I 11.t,;d ,ilil _y
~
,
·•
1p111
T('ad1 i11g F1·ll11w : 1',nj v,,I l ':tlil
l>;ifl': (; l)( '( '( ' IIJI H 1 I
:m~ ,
Ti1tt1' : 10:!Hl :1111 l o I 1,rr1
IN~T lll lCTIO NS:
•
Y\>IJ IIIT
p1•1111if fl•d fn bring a singl<' J\ I lu111d wr it t, ,11 rd ·, ,11 , 11 , ., ,.
• Tlrl' r1·fen' J1CP sh1'1' t. slro11ld 1101, h<' s hnn•d wi t Ir 11 11y t 1"d.Y
• The n.f1•n 'lll'P sh1'1•t 11111st. hnv<' IH•1•n wrif f,1 •11 by .Y""·
s wr•r iwript s.
• Thl' rl'fl'rl'll<"<' sl11•1' t 11111st, Ill' s11lmiitt1•d alo11g-w if,l1 yc111r ;u 1
0
r: fr11·1nrd a all'l
• nl'for<' ~· 11 a11sw1' r a q11pst.io11 , ple;ise s tate tire a ppropr ia t
,·alu1's.
r;r1 rr< •l'l,Jy
~ril 1·,t it,,,,,
= ~~G, <"rmiJJIJtr~
.l cdf)
(~·ou can state the answe rs in terms of ¢ (.) Lbe s La nd a rd r1rJrrrn1
and
1. If Xis a norma l rando m variab le wiLh param cLC'rs 11, = ]()
f'J2
(a) P(X > 5)
(b) P( 4 < X < 16)
(c) P(X < 8)
(6 m ::trks)
2. Let X 1, X2 .. . Xn are n rando m variab les a nd let l 1 , t 2
. ..
l"
be n real
n,1 mbr•r<,.
Prove that
(G rrn:1rk.,J
vari,1Llr~
rn
3. The numb er of ticket s issued by railway employee is a Pois~o n rando
it is empty . \\ lt,1t
with rate 10 ticket s per hour. You arrive at Lhe counL er when
J~<· y<Jll li,1'.''
is the proba bility that you will spend at least 15 rninu Lc·s? Supp<
is tit<· pr<Jb,1l1ili1_y
alread y spent 15 minut es at the front of Lhe counLcr, what
(G Ifl,1rL.,J
that you will spc•nd at most anotlw r 5 rni1111l ('s.
4. Let X be a rando m variab le with Lbe d<'11s ily sltow11 l><'i<>W .
f(x)
I
0.75
0.5
0.23 .,__ -~
0} 2
;3I
y
=.:: {
J,
-·
')
fur O <
fur 1 ·
.r ,..
r •
'2
:l
t
( ' , ,i I I} , 11 11•
Ii•~( \ j ) ) • \ ' 11 1 (
\
j) ) / ( \
f (I )
' 11 1 ( \
I) ) .
V 11 1 ( 1..: ( \ \ ) ) ) V n 1 (
I /.j')
1
',!,IP I '(/,/2)
1
I I :\
\ ) (
1 ,(
I I.
1 /.
1/ /
Sh 11w lh;it rt is a SjH Ti:d 1·:1~>1• c,f 1•,:1111111:t d ist.ril ,1 11.11 111 l,1·1 'I. I,,. :,l:11 1d ,111 I 11111111:il
1
l,11 d1 i •,1111:11 /'d 1,dl 1
II 11w ·IS II 11 : I>' If r>f X 1·1l·1l1·1l
I ,1'1. ,\'
·
• • •
h' 'l .
d1st 11 1111t11l11.
(:\ I ~ I:\ 111:11 k•,)
D1•d1H·1• the• v,il1H' of 1'( I / '2)
(i .
Crnisi, kr a n ,·x111•ri11w11t. wlwrc l H•rno111 1i I. ri a ls a rc• rc·1wat.,·rl t.i 11 t.111• fir•,t f w;,,I ,.,
ohS('l'\'('(l. Ll'L X d1•111,u~I.lie rnt1cl(IJJ1 vari:il ,lc : whic:11 (;(Jlllll.S t.111: 11 11 1111 >"1' l:iil11ws
in th is l'X)HTi ll H'll L Ld IIS c:all I.Ill' cl is LrilJ1 i1 ic,11 ,,r X as 1111sl1 if1.<·d i•,t ·<1111,·t.ri1·
,ir
,list ri li11 t ion .
(a) llow is t his n ·lnt.1 ·d to t.111• ).',<'<J11wt.ri1: rnnd<Jll l vari al1lc disc: 11ss1•d i11 I IH· c-1:,ss'!
( I I 2 I 2 rw,rks)
(h) \ \ili at is t.li<! E(X), V:tr(X)?
G Ll'I X 111Hl Y lie iid H.Vs a n,l k t. / '( X = k) =
If I'(X
=
l \X
+Y = l) =
!'(X
= t-
71k
1\ X
> 0,
k
= 0, I , 2, .. .
l
+ Y = l ) = li=!' l
~ 0
t1H'JJ s lrow tlr aL X a nd Y a rn 1111sli ift.1:<l G,:0 111<:l.ric rn11.durn VfLri,d ,h: (,h:!'11H·<l in
( l'2. 11m1ks)
tli c q 1l<'stio11 a bove)
e h e a uniform ra wlorn vari a lJlc s 11pporLcd i11 t,/11: r:.u,gc {- 1r, 1r]. Pi x I,- > U.
We d,~finc random vari able
~ Let
T((➔)
= E-) + tan- ' (k tan((-)))
Yo 11 m ay a.ss1m11! t lit' foll owing wit.lio11t p rnr,f
(a) Tis a u odd fu11 r:ticm T(:c) = - T (- :1:)
1
(b ) t a u (L) liy ,·011v1•11ti1m rn aps IP. (n ·al 11 1111il,ns) lo va l1ws IH·I w1·1·n [ -
Cc) Tis stric·tly m<JIHJl<J1iic;11ly i1wn ·:Lsi11g i11 I 111 • 1a111•.i · [O, 11/~) T ((J)
T (rr/'2) = 1r
(d) Ti~ strictly 1111J1H,l.r111 i1·al ly i1w11·asi11µ, i11tl11 •1,11 1/•,t·( 11/'.!. ,11). l11 1111
0 a wJ T( rr) -= 7T
k) Fi,r 1·\·,·ry (/ r (II. 11 ), llw11 · <·xi-.ts 0 1 ;1 11d Oi
'1'(0 1 ) (/
t l1at 'J (Oi)
(f ) t,,u(O t
)
- , ,,, (0)
(r,) l i111((J - rr / 'l)
< 1,t (O)
(11) I 11t (lJ j -·
11 /'l
,..1,. 11
,1 -,
.~
;r
/2. ,T / '2]
(/
,111 d
'/'(IJ J
-
slH,1111 111 li;•,1111 • l,d., 11 ~111 Ii
a :--t ' 1'. 1'S
uf :-- t<·ps \\'(' wonlcl lik<' to s li ow11 11, nt T ((-)) is a lso 1111iforr11ly
tnl111kd 111 tht' rn ng(' [-1r, lT)
H_,·
vf.1 )
cl1 s-
In tcnn:-; of O, il lld 0-i (r<'fcT tl1< ' (ig m <' lwlow) wril<: t.lH' <·xprc·ssio11 for
0 i+ ~ 2- - ITJ2..
I'(T( (-)) C:. [O. (/ ])
};jl...(li) _To J~r~v~ _th~it, T(G) is unifo~~ri dis tri ~m t~,c.I in t he rnngc [-~, '7T], we can
,1ltcrnc1tn,rl_i, ~h~,~ tha~ P(f(G) E [O, 0 ]) IS equal to a ccrtam numerical
nll uc? \ Vhat Is It?
~)C /~r)
~ LE't 03 = 0' - 01 + '7T /2. Show that 03 E [7r /2, 7r]
J<l) Show that k tan(03 ) = - cot(01) .
y)
r
A#:_
Show that T(03) = 0'. From here show that T(8) is uniformly c.lis triuutc<l
in the range [-'lT, 7r]
(f) Recall that for every random variable there is an implicit probability space.
Prove or disprove with an example that {w : a ~ G(w) ~ b}
= {w : a
~
~c_,,,.-- ~----~ ,
~.,._ t,,, -
~ :/
T(A)
~
n
¼ ,
rr, 2
o,
-n
J.
~( u.1 )= ,'\ 1\
\ (2+3~2+4+7= 18 marks)
T(0(w)) S: b}
A tourist arrives at a Goa casino with Rs k (positive integer) . He gambles in a
casino and plays a particular game where is he gains a rup ee with probabilily
0.5 and loses a rupee with probability 0.5. He gambles co11tim1ously till one of
the following happens - he reaches Rs N (some positive integer) or loses all his
money. ~lode} this as a discrete time Markov chaiu. Compute the probability
that he stops by reaching Rs N. vVhat is the eXJ){'C'LecJ 1111111bcr of rn 1111ds t hl'
(5+ 7 +8 = :.W 1uarks)
gambler plays?
10. This CjUest.ion has uo c:orred answer as loug as yo u atll'lllpt it rn111plt'lt•ly. Li.-.1
down IO topics taught in the ,·,uus1:. Arrn11g<' t.lH'S(' t.opi<'s ill t ltt• ord1•r ill ,, lt id1
you like them, the topmost l,ciug tlw rnost. iut1 ·n·sti11g topi<'. Si111darly, ;1rr,111g 1'
these topics in the onln iu which you havP uud1·1~loud I lw111, t ltt• lup111osl l,1•i1tg
(:i 111 ;11-k:-i )
the most well uudnstood topic.
-
Related documents
Download