This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: CSE 3101Z Design and Analysis of Algorithms Professor: James Elder Winter 2009 Assignment 1 Due 11:59pm Monday March 30 1. Universal and Existential Qualifiers (8 marks) Recall that a problem is computable if and only if there is an algorithm that halts and returns the correct solution on every valid input. Let Works ( P,A,I ) be true if and only if algorithm A halts and correctly solves problem P on input instance I . Let P = Halting be the Halting problem which takes a Java program I as input and tells you whether or not it halts on the empty string. Let P = Sorting be the sorting problem which takes a list of numbers I as input and sorts them. (a) (4 marks) Express using universal and existential qualifiers ( ∀ , ∃ ) that Sorting is computable. No justification is required. • Answer: ∃ A, ∀ I,Works ( Sorting,A,I ). There is at least one algorithm, eg. A = mergesort , that works for every input instance I . (b) (4 marks) Express using universal and existential qualifiers ( ∀ , ∃ ) that Halting is not computable. No justification is required. • Answer: ∀ A, ∃ I, ¬ Works ( Halting,A,I ) Every algorithm fails to work for at least one input instance I . 2. Bounds (15 marks) We use the logical connective → to represent a logical implication, consequence or entailment. For example, the proposition Statement 1 → Statement 2 means that if Statement 1 is true, Statement 2 must also be true. If f ( n ) and g ( n ) are two functions of the positive integer n , which of the following propositions are true? Please prove the ones you believe to be true, and provide a counterexample for those you think false. (a) f ( n ) ∈ Θ( g ( n )) → g ( n ) ∈ ω ( f ( n )) • Answer: False  in fact, the negation is true: f ( n ) ∈ Θ( g ( n )) → g ( n ) / ∈ ω ( f ( n )). If, for example, g ( n ) = f ( n ), then f ( n ) ∈ Θ( g ( n )), but g ( n ) / ∈ ω ( f ( n )). To see this, recall that g ( n ) ∈ ω ( f ( n )) → ∀ c > , ∃ n > 0 : ∀ n ≥ n ,g ( n ) > cf ( n ) , but clearly the latter is false for c ≥ 1. (b) f ( n ) ∈ Ω( g ( n )) → g ( n ) ∈ O ( f ( n )) • Answer: True. To see this recall that f ( n ) ∈ Ω( g ( n )) → ∃ c 1 ,n 1 > 0 : ∀ n ≥ n 1 ,f ( n ) ≥ c 1 g ( n ) We must show that this implies that g ( n ) ∈ O ( f ( n )), i.e., that ∃ c 2 ,n 2 > 0 : ∀ n ≥ n 2 ,g ( n ) ≤ c 2 f ( n ) , which follows by setting c 2 = 1 /c 1 and n 2 = n 1 . (c) f ( n ) ∈ Ω( g ( n )) → g ( n ) ∈ o ( f ( n )) • Answer: False, and, in fact, impossible. For example, f ( n ) = g ( n ) → f ( n ) ∈ Ω( g ( n )), but g ( n ) / ∈ o ( f ( n )). To see this, recall that g ( n ) ∈ o ( f ( n )) → ∀ c > , ∃ n > 0 : ∀ n ≥ n ,g ( n ) < cf ( n ) , which is false for c ≤ 1. (d) f ( n ) ∈ O ( g ( n )) → g ( n ) ∈ ω ( f ( n )) • Answer: False. For example, suppose that f ( n ) = g ( n ). Then clearly f ( n ) ∈ O ( g ( n )), but g ( n ) / ∈ ω ( f ( n )). To see this, recall that))....
View
Full Document
 Spring '09
 liliaNE
 Algorithms, Halting problem, Semitone, Equal temperament

Click to edit the document details