2007.semester.2.key

2007.semester.2.key - C8202 DISCRETE MATHEMATICS SEMESTER...

Info iconThis preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 4
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 6
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: C8202 - DISCRETE MATHEMATICS SEMESTER EXAMINATION 2 FALL 2007 Time Limit - Sevenfl Five Minutes This is a closed book, closed notes examination. The numbers in parentheses after each question is the number of points allocated to that question. Write your answers on the examination paper in ink or legible pencil. I our answer cannot be read or understood or i our answer is vague or confused, it will be marked wrong. NAME (Print Legibly. All Cagitals): PLEDGE (Write Out In Full And Sign): Department of Computer Science CS 202 University of Virginia 1. Prove by induction that: (10 pts) n Zri = (r”+'—1)/(r—l) i=0 3:. +6 '5» Os 9 O“ ,r; r _1,r-1:r -1 5:9 ' \'~ r-4 n+1)“ .. . «H A _ JV“\“C+WC S‘H’?‘ g rL _ (“‘4 we Wei film-A HAM Z r‘ : i _A$§Uwuncl 1° ~ (“-1 ’ [:0 r4 . .4 mu n+1 ’l 1 VEH- “H+%r‘ ~ (“Hib‘q “ML-l — “A “r " ’1 r AMH‘ - + - .. 1:9 r [:0 ("'1 r‘( r“ 1‘" (32.5."D 2. A real number r is rational if there are integers p and q with q ¢ 0 such that r = p/q. Prove using a direct proof that if r and s are rational then r + s is rational. (10 pts) Six/ma r- WA 5 Ma rcuh'onaei, flare exi$+ (vii-26103 05b, gamdal swan Jame r: an, “an, auva new 5 MAM 3w». ‘flm {ml—egm are. clo‘SaA uvxc\e)f‘ aclciii'iew C(Mtl. Mui‘HPh'Cfif‘bV) $0 *‘lDC l" cw (“713W MA. \03« is cwx‘ml-e$2f. giwce modal-Lax lama-oi is Sore. lag» is wuvjexb. m5, Lt‘ A,» I'm '00) “AH” is rodwéwki- LJ, v Q “(‘7 ‘ ‘ - Svmc; h +5 = A, + z b; ‘ helmet \3 rqhowqi’ f+g "S rathéml, a5 was «in» be 4w“. 3. Prove using a proof by contradiction that for any integer n, if 3n + 2 is odd, then n is odd. (10 pts) Suwose ~l-o ‘l'luz. Con‘l'rwrbl JAM} We»: is $9Me ;M‘\>e¢3a¢~ W such M 313+; is 6AA lowl VLis wow. '31 MM. c\,4\'u(Jném5 0? 05M WA gum, ‘H’UUI £435" (“13% q WA l) such ‘uhaui' 3n+1=2a+l awxci m=2l>_ Subsaifl-M'Hm (11¢,le 5(1Hi’2 =24+i’ $0, solu‘mS ¥D¢ lo, M M 5:35” W5 15 my? 4M $447939!" $0 we \Aawc rectal/mi a unhaol'mi'fcn. Page score Department of Computer Science CS 202 University of Virginia 4. How many total functions are there from a source set of three elements to a target set of two elements? Carefully explain your answer. (5 pts) 8. «pungj-iam i5 gr each twain," O? 'HALwUfa 52+, ‘0. Wylyb'ma' wad $e+ es T={€.,ée§ owl “4‘ $09M 5* “3 S'isttSa-Ss 3' HM “is” fumhees “‘5 “‘W ’t “NW “#03 { (Soto), been, (939:1? 5 {(54'tt); (Epic ), (531t2)} 161, ‘33,), (522%,), ($3, :1); {(51t£1)1(52_ybz),(53)t1)% {(Shtz)’ (5mb1), (S3, , } ‘Z (sues), (51,151), (534:1); =1 (Shea), (slim), (53,12); 5. How many partial surjective functions are there from a source set of three elements to a target set of two elements? Carefully explain your answer. (5 pts) 1.?- A th'wl Suded'k 'FVwch’O-fl cougrs HM. c‘l’ Sci" secleMohln$ Source. 36‘, “ S={5h51’53} W ‘HM. 55+ 6 T: if“ z E, M ‘lchuc Pun/\Chofls km‘. (sum, (syn) E {with}, (sate)? {(5.,4:t),($,.£n_), (sate)? (fill-£1), 53't‘)} { (51’ fig), (52,£1) } {I (5“ E2), [Sl’eq )1 (531t1)} {(511‘E4 )l { ($4,€( )| (Sz’tl), { (${,£2); (SZIt‘ )I (fines). (Seth)? { Ls.,4:,), (sate), (swept .{ (5,, ea), (5;:‘52’153'tfl? 6. Suppose f is a function whose source set is the letters of the alphabet and whose target set is the positive integers, and g is a function whose source set is the positive integers and whose target set is the letters of the alphabet. If the functions f and g are defined as follows: f: {(a, 2), (b, 4), (Ci 1), (d, 5), (e, 3)} g = {(1,3) (2, b), (3, C), (4, d), (5, 6)} (a) What is the definition of the function g of? (5 pts) gear : Maintain), me), (the), up} (b) What is the definition ofthe function fo g 7 (5 pts) tug =f(1,a),(2,‘+l,(5:13,WIS), (5,5)} (0) What is the definition ofthe function f” o g'1 ? (5 pts) f’18‘1={tn,e), (5,4), (52), (it), (cm; (d) What is the definition ofthe function g'1 of" ? (5 pts) 3’ 91/413091), (4,2), (4,3), (574), (3,5)} Page score Department of Computer Science CS 202 University of Virginia 7. Using an i f statement as an example or otherwise, carefully explain what is meant by syntac- tic ambiguity in common programming languages. (5 pts) A iquuasz con‘tm’ns a 5'1quch 5 mbfau/(i-xj if a val (A, warm in //l \ ‘ .. ‘ ¢\ 5 (ten/miner?ch (1n vvwd 'plc ‘i: 61%“ 5 -w ng< z m 5;: //' \\ $9 HM $4 (daup- atfiwtmb "x gwsfljsesz \ “if a, Haw if (Ii-kw 513‘52 5;”, i2!" Welt, Couloi be. PM «$2 8. Using a for statement as an example or otherwise, carefially explain what is meant by seman— tic ambiguity in common programming languages. (5 pts) A COW‘i’hllfl—5 Q SOMAch mb\,8u1¥3 RS; ‘HKUL are some (Daze-t Waste/MS whose vuwa «I; mi» ’pmciseiul 44"" \2, ix» We. woeva Qrafiumt “4:”— x, grown t +5 to be! 1 Ac 5 “A QM)", it \s unclear whiz-Hater, “(H—o»- iln— (:rASMMt 13 waged-car, 7: shard; log 10’ H, 0r Manama 9. Consider the following piece of program (the parenthesized numbers are line numbers): (1) i, n, factorial : integer; <2) (3) i = 1; (4) factorial := 1; (5) read(n); (6) (7) while i < n loop (8) i := i + 1; (9) factorial := factorial * i; (10) end loop (11) (a) What is the loop invariant for the while loop? (10 pts) I .— ’l ‘Faci’orial ‘ l. (b) Before execution of which line or lines should the loop invariant hold? (5 pts) “flu. \009 \iAuaurimAt Med)»; Mei-Eyre \eres (5 «and to cure 8—)Lccuie¢i, Z-i clo¢s V\o+ \oefofe ii“ 0! is e/yecpei’edt. (c) The use of a loop invariant facilitates proof of the correctness of program loops using what proof method? (5 pts) (Proon \n‘ \lwiuc‘hlon. Page score Department of Computer Science CS 202 University of Virginia 10. Consider the grammar G = (V, Z S, P) where V: {0, 1, A, B, S}, T= {0, 1}, S is the start sym— bol, and the productions P are: S—)0A S—)1A A—)OB B—)1A B—)1 (a) By drawing the derivation tree, show that the string 10101 belongs to the language gener— ated by G. (5 pts) \k \ if? I 01 101 (b) By showing that you cannot draw the derivation tree, show that the string 10110 does not belongs to the language generated by G. (5 pts) 5\ We have no choice loul' +0 «PP‘LI Was; A\ Freda-4,415.45 im ‘HA‘lS ordzr) bwk Hare 3\ is Vlo Wcluch‘an gr A 'HAQl' jwwas‘l’tS { A C; 6‘1?in \OC‘3\\:\V\'\1A3M;\\'L\ a 1 . 4 O 1 (c) What is the language generated by G? (An informal answer is sufficient.) (10 pts) [o1](o1)+ m $61, a 6H<n35 beginning) w'iHa a 0 w c. 1 Rllowed lo“ M av More. reechh'mms (Zr ‘HN. Sulos‘l‘rlujg of. ((1) Draw the finite state automaton that recognizes the language generated by G. (10 pts) Page score Department of Computer Science CS 202 University of Wrginia ll. For a directed graph G, the vertices are {v1, v2, v3, v4, v5} and the edges are {e1, e2, e3, e4, e5}. The edge—endpoint function is: (a) List the degree of each vertex. (6 pts) Ver+mfw ‘anV3IVwIV5 1 olefimc 9'1 3 2 3» M V, O 1 O 0 o (b) What is the adjacency matrixA for G? (6 pts) V1 0 o 1 o 0 v3 0 o o o o air—>- 4 O 1 o O i V5 4 o 0 0 o (c) Is there a cycle for this graph? If so, give it. If not, explain why not. (6 pts) q CW ‘0‘- ‘l'bpolo (Ca-Jith sari-eel, 41y. lV‘ 'HAis ‘me’ Slit/ICC. 'HAerg are 3 “0 backwmclr 1113‘s, H‘ is v.1. -> V —-—a v‘( _-a Va ——9 VJ C(W .HAOJ. “Ava M¢ Mo dad‘s. V 12. If two cards are dealt from a well shuffled card deck, what is the probability that they are both aces? (6 pts) , 74mm 0M WA” 51CWL’3 lad-(arc 52 5/ x-lLa P364 Arm awc ~H4rce [L54 «flatuw. 13. How many alphabetic character strings (ignoring case) of length four are there that start and (C 9’ end with a vowel (not counting y as a vowel)? (6 pts) 5.16-2.45 Page score ...
View Full Document

This note was uploaded on 10/10/2009 for the course CS 2102 taught by Professor Knight during the Spring '08 term at UVA.

Page1 / 6

2007.semester.2.key - C8202 DISCRETE MATHEMATICS SEMESTER...

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online