12.07.2015 Views

ECE 203S — Discrete Mathematics Instructions 1. /10 2. /14 3. /12 4 ...

ECE 203S — Discrete Mathematics Instructions 1. /10 2. /14 3. /12 4 ...

ECE 203S — Discrete Mathematics Instructions 1. /10 2. /14 3. /12 4 ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Name:Student No.:University of TorontoFaculty of Applied Science and EngineeringDepartment of Electrical and Computer EngineeringMidterm Examination, February 25, 1999Second Year — Programs 7 and 9<strong>ECE</strong> <strong>203S</strong> — <strong>Discrete</strong> <strong>Mathematics</strong>Examination Type: Closed BookExaminers: B. Bardakjian, C. and S. Borac, F. Kschischang<strong>Instructions</strong>• This examination paper consists of six [6] pages (including this one). Please make sure thatyou have a complete paper.• Write your name and student number in the space provided at the top of each page. Pleaseenter the first letter of your last name in the box at the bottom left corner of this page.• Answer all five [5] questions. The value of the questions is noted on each page. A total of60 marks is available.• Answer each question directly on the examination paper, using the back of each page ifnecessary. Please indicate clearly where your work can be found.• Show your work! Show all steps and present all results clearly. State any assumptions thatyou make.• If we can’t read it, we can’t mark it. Please be neat, and use ink.• Calculators are not permitted.• Time: 1 hour, 50 minutes.Enter the first letter ofyour last name here.Examiner’s Report<strong>1.</strong> /<strong>10</strong><strong>2.</strong> /<strong>14</strong><strong>3.</strong> /<strong>12</strong>4. /<strong>14</strong>5. /<strong>10</strong>Total: /60Note: this exam was originally printed on legal-size paper, giving students more space in which towrite their answers.– page 1 of 6 –


Name:Student No.:<strong>1.</strong> In each part of this question, you will receive 1 2mark if you answer correctly, zero marks if youdo not answer, and − 1 2marks if you answer incorrectly. This question is worth a minimumof zero marks and a maximum of <strong>10</strong> marks.Let A, B, and C be sets. Let Z be the set of integers, and let N be the set of non-negativeintegers.True or False? (Please circle T for true and F for false.) In some cases, it might be helpfulto draw a Venn diagram.(a) {2} ∈ {1, {2}, {{3}}}. T F(b) {2} ⊆ {1, {2}, {{3}}}. T F(c) {a} ∈ P ({a, b, c}). T F(d) {a} ⊆ P ({a, b, c}). T F(e) If A ∪ B = A then A ⊆ B. T F(f) If A ∩ B = A then A ⊆ B. T F(g) If P (A) = P (B) then A = B. T F(h) If A ∩ B ≠ ∅, then (A ∩ B) ⊆ (A − B) ∩ (B − A). T F(i) (A ∪ B) − (A ∩ B) = (A − B) ∪ (B − A). T F(j) (A − B) − C = A − (B − C). T F(k) (A − B) − C = (A − C) − (B − C). T F(l) |{x|x ∈ N and x 2 ≤ x}| = <strong>2.</strong> T F(m) |{x|x ∈ Z and x 2 ≤ x}| = <strong>2.</strong> T F(n) A ∈ A × B. T F(o) If A ≠ ∅ then A ⊆ A × B. T F(p) If B ⊆ C then A × B ⊆ A × C. T F(q) If A is not empty then A and P (A) are disjoint. T F(r) If A is not empty and B is a proper subset of A then A − B is not empty. T F(s) If A ⊆ B and B ⊆ C and C ⊆ A then A = B = C. T F(t) |P (P (P (P (∅))))| = 2 16 . T F<strong>10</strong>marks– page 2 of 6 –


Name:Student No.:4 marks<strong>2.</strong> (a) Use truth tables to prove or disprove each of the following logical relations:i. a ∧ (b ∨ c) ⇒ (a → b) → c.4 marksii. (a ∧ b) → c ⇔ (a → c) ∨ (b → c).6 marks(b) What logical conclusion (of no more than <strong>12</strong> words) can you draw from all of the followinghypotheses:i. If John goes to a party, he does not fail to brush his hair.ii. To look good, it is necessary to be tidy.iii. If John is an alcoholic, then he has no self-command.iv. If John brushes his hair, he looks good.v. John wears black gloves only if he goes to a party.vi. Having no self-command is sufficient to make one look untidy.<strong>14</strong>marks– page 3 of 6 –


Name:Student No.:6 marks<strong>3.</strong> (a) State and prove the first form of the theorem on mathematical induction.6 marks(b) Use the theorem of mathematical induction to prove that for all positive integers n,n−1∑k=01(n + k)(n + k + 1) = <strong>12</strong>n .<strong>12</strong>marks– page 4 of 6 –


Name:Student No.:4. Consider the following functions from R to R, where R is the set of real numbers.(i) f 1 (x) = x 2 + 4.(ii) f 2 (x) = x 3 − <strong>3.</strong>(iii) f 3 (x) = 11+e −x .3 marks(a) Determine whether each function above is an injection, surjection, bijection, or none ofthe above.3 marks(b) For each of the above functions, find the inverse function if it exists.2 marks(c) Find the composition of functions (f 3 ◦ f 2 )(x).3 marks(d) Choosing from the polynomial family {1, x, x 2 , x 3 , . . .}, give as good a big-O estimate aspossible for each of the above functions.3 marks(e) Rank the above functions using the big-O notation, i.e., for each pair of functions f i andf j , decide if f i is O(f j ) or vice-versa.<strong>14</strong>marks– page 5 of 6 –


Name:Student No.:5. Let us define a byte as an integer that can take on a value between 0 and 255 (inclusive). Abyte-sorting algorithm takes a list of a 1 , a 2 , . . . , a n of bytes and permutes the list to form anew list a ′ 1 , a′ 2 , . . . , a′ n with the property a ′ 1 ≤ a′ 2 ≤ · · · ≤ a′ n.Following are pseudocode descriptions of two different byte-sorting algorithms.procedure SelectionSort(n : integer, a 1, a 2, . . . , a n : bytes)1 for i := 1 to n − <strong>12</strong> begin { find the smallest element among a i, . . . , a n }3 m := i4 for j := i + 1 to n5 begin6 if a j < a i then m := j7 end8 interchange a i and a m { a m is smallest }9 end<strong>10</strong> { now a 1 ≤ a 2 ≤ · · · ≤ a n }procedure CountingSort(n : integer, a 1, a 2, . . . , a n : bytes)1 { b 0, b 1, . . . , b 255 is an array of integers }2 for i := 0 to 2553 b i := 04 for i := 1 to n5 b ai := b ai + 16 { b j now is a count of how many times j occurs in the input list }7 i := 18 for j := 0 to 2559 begin<strong>10</strong> if b j > 0 then { if j occurred . . . }11 begin<strong>12</strong> for k := 1 to b j { . . . put b j copies back into a }13 begin<strong>14</strong> a i := j15 i := i + 116 end17 end18 end19 { now a 1 ≤ a 2 ≤ · · · ≤ a n }1 mark2 marks3 marks(a) Give big-Θ estimates of the average-case and worst-case running times of the inner loopof SelectionSort (lines 4–7) as a function of i.(b) Give big-Θ estimates of the average-case and wort-case running times of the SelectionSortalgorithm.(c) Give big-Θ estimates of the average-case and worst-case running times of the followingloops in CountingSort:i. Lines 2–3ii. Lines 4–5iii. Lines 8–182 marks1 mark1 mark(d) Give big-Θ estimates of the average-case and worst-case running times of the Counting-Sort algorithm.(e) Which of the two algorithms would you prefer for sorting a short list (say n ≤ <strong>10</strong>) ofbytes? Justify your answer.(f) Which of the two algorithms would you prefer for sorting a long list (say n ≥ <strong>10</strong>00) ofbytes? Justify your answer.<strong>10</strong>marks– page 6 of 6 –

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!