{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

CSC236H-d06 - ’0(0 UNIVERSITY OF TORONTO 4‘96 Faculty...

Info icon This preview shows pages 1–12. Sign up to view the full content.

View Full Document Right Arrow Icon
Image of page 1

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

View Full Document Right Arrow Icon
Image of page 2
Image of page 3

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

View Full Document Right Arrow Icon
Image of page 4
Image of page 5

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

View Full Document Right Arrow Icon
Image of page 6
Image of page 7

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

View Full Document Right Arrow Icon
Image of page 8
Image of page 9

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

View Full Document Right Arrow Icon
Image of page 10
Image of page 11

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

View Full Document Right Arrow Icon
Image of page 12
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ’0 ((0 UNIVERSITY OF TORONTO 4‘96 Faculty of Arts and Science '94 DECEMBER EXAMINATIONS 2006 $0 030 236H1 F /¢ St. George Campus Duration — 3 hours Aids allowed: none Student Number: I I I I I I I I I Last Name: First Name: Do not turn this page until you have received the signal to start. (In the meantime, please fill out the identification section above, and read the instructions below.) This examination consists of 9 questions on 12 pages (including this one). When you receive the signal to start, please make sure that your copy of the examination is complete. If you need more space for one of your solutions, use the reverse side of the page and indicate clearly the part of your work that should be marked. For 1 bonus mark: write your student number at the bottom of pages 2—12 of this test. Good Luck! Total Pages = 12 Page 1 #1; #2: #3; #4: #5; #6: #7: #8: #9: TOTAL: CONT’D. .. CSC 236H1 F FINAL EXAMINATION December 2006 Question 1. [10 MARKS] Prove that 4”+1 + 52"“1 is a multiple of 21 for all natural numbers n 2 1. Student #2 Page 2 of 12 CONT’D. .. CSC 236H1 F FINAL EXAMINATION December 2006 Question 2. [12 MARKS] Prove that the following code for converting a binary representation int b to a number is correct: // Precondition: b is of type int . int x = 0; int i = 0; while (i < b.1ength) { x = 2 * x; x = x + b[i]; i = i + 1; } Postcondition: b.length—1 :1) = Z 1) [j] . 2b.length—J—1 i=0 Note that the 0th index is being treated as the leftmost bit. Hint: when you ‘weaken’ the Postcondition to make part of your Invariant, you should change two parts of the Postcondition. Student #: Page 3 of 12 CONT’D. .. CSC 236H1 F FINAL EXAMINATION December 2006 Page 4 of 12 CONT’D. .. Student #: CSC 236H1 F FINAL EXAMINATION December 2006 Question 3. [8 MARKS] Consider the following code: // Precondition: x and y are positive. int a = x; int b = y; while (a != b) { if (a < b) { a = a + x; } else { b=b+y; } } // Postcondition: a is the smallest positive multiple of x and y. // (in other words, a is a positive multiple of x and y, // and is no larger than any positive multiple of x and y) Part (a) [5 MARKS] State an appropriate loop invariant. Part (b) [3 MARKS] Assuming the loop terminates, use the invariant to prove the program is correct. Student #: Page 5 of 12 CONT’D. .. CSC 236H1 F FINAL EXAMINATION December 2006 Question 4. [6 MARKS] Let P, Q and R be Propositional Variables. Express “exactly two of P, Q and R” are true, with a DNF formula and then with a CNF formula. Question 5. [7 MARKS] Produce a formula in Prenex Normal Form that is logically equivalent to: (3111400731) -> V963W 21)) /\ (flow 3!, 2)) Student #1 Page 6 of 12 CONT’D. .. CSC 236H1 F FINAL EXAMINATION December 2006 Question 6. [7 MARKS] Prove that (P V Q) A (-IP V fiQ) LEQV (—‘P /\ Q) V (-162 /\ P) using the standard propositional equivalences listed below, without using truth tables or truth assignments. Standard Propositional Equivalences: sfiP LEQV P —.(PAQ) LEQV st—1Q —.(PVQ) LEQV fiPA—IQ PAQ LEQV QAP PVQ LEQV QVP PA(Q/\R) LEQV (PAQ)/\R PV(QVR LEQV (PVQ)VR PA(QVR LEQV (PAQ) PV(Q/\R LEQV (PVQ) PA(QVfiQ LEQV P PV(Q/\—uQ) LEQV P PAP LEQV P PVP LEQV P P—>Q LEQV fiPVQ PHQ LEQV (PAQ)V(—uP/\-1Q) VVVV Student #: Page 7 of 12 CONT’D. .. CSC 236H1 F FINAL EXAMINATION December 2006 Question 7. [10 MARKS] Let EB be a new binary operator of propositional logic representing “exclusive or”: T*(P) EB 7*(Q) is 1 iff exactly one of T*(P) and T*(Q) is 1. Prove that there is a boolean function from {0,1}2 —) {0,1} that can’t be represented by a Propositional Formula built from the propositional variables PV = {:r, y} and operators {V, A, 69}. Student #: Page 8 of 12 CONT’D. .. CSC 236H1 F FINAL EXAMINATION December 2006 Question 8. [10 MARKS] Let L be a first-order language with (at least) the variables x and y. Give a definition by structural induction of the following function replace: For first-order formulas F: replace(F) = F with all free x’s replaced by y. Student #2 Page 9 of 12 CONT’D. .. CSC 236H1 F FINAL EXAMINATION December 2006 Question 9. [20 MARKS] Part (a) [5 MARKS] For each state in the following DFSA (dead states not shown), give a regular expression corresponding to the strings that end in that state. Part (b) [5 MARKS] Prove that if a DFSA accepts the language of reversed binary representations of multiples of 3, then the DFSA requires at least 3 states. Student #2 Page 10 of 12 CONT’D. .. CSCZ36H1F FINAL EXAMINATION December 2006 Part (c) [5 MARKS] Draw an NFSA with at most 3 states that accepts the language described by the regular expression a* b* a*a. Part (d) [5 MARKS] Suppose L1 and L2 are regular languages over the same alphabet A. Must the language {s E A* : if s 6 L1 then s 6 L2} then also be regular? Briefly justify your answer. Page 11 of 12 CONT’D... Student #: , , “1"“ 080 236H1 F FINAL EXAMINATION December 2006 Total Marks = 90 Student #2 Page 12 of 12 END OF EXAMINATION ...
View Full Document

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern