sol-quiz2 - CMPT 307 Solutions to Midterm #2 November 13,...

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

View Full Document Right Arrow Icon
Solutions to Midterm #2 November 13, 2008 1. True or False? (Below, Pr [ X ] stands for the probability of an event X .) [3] (a) For any random events A and B , Pr [ A B ] = Pr [ A ] · Pr [ B | A ]. (b) For any random events A 1 ,A 2 ,...,A n , Pr [ A 1 A 2 ∨ ··· ∨ A n ] = n i =1 Pr [ A i ]. (c) For independent random events A 1 ,...,A n , n i =1 Pr [ A i ] 1. Solution: (a) and (c) are True; (b) is False. 2. Explain very briefly why any comparison-based sorting algorithm will take time at [5] least Ω( n log n ) to sort n items. Solution: There are n ! possible orderings of n elements. A correct comparison-based algorithm must be able to produce any one of these orderings. Viewing the comparison- based algorithm as a decision tree, this means that the tree has n ! leaves. But then it must have at least log( n !) = Θ( n log n ) height (= running time of the algorithm). 1
Background image of page 1

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

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 11/23/2009 for the course CS 307 taught by Professor A.bulatov during the Spring '09 term at Simon Fraser.

Page1 / 4

sol-quiz2 - CMPT 307 Solutions to Midterm #2 November 13,...

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

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