Homework 3.pdf - Google Drive

0 downloads 175 Views 71KB Size Report
Page 1 of 3. Homework 3 參考解答. 1. First, let's clarify what the function max (݂(݊), ݃(݊)) is. Let's define th
Homework 3 參考解答 1. First, let’s clarify what the function max( ( ), ( )) is. Let’s define the function ℎ( ) = max( ( ), ( )). Then ℎ( ) =

( ) if ( ) ≥ ( ), ( ) if ( ) < ( ).

Since ( ) and ( that ( ) ≥ 0 and Thus for ≥ , ( (

) are asymptotically nonnegative, there exists ( ) ≥ 0 for all ≥ . ) + ( ) ≥ ( ) ≥ 0 and ) + ( ) ≥ ( ) ≥ 0. Since for any particular , ℎ( ) is either ( ) or ( ), we have ( ) + ( ) ≥ ℎ( ) ≥ 0, which shows that ℎ( ) = max( ( ), ( )) ≤ ( ( ) + ( )) for all (with

such



= 1 in the definition of Θ).

Similarly, since for any particular , ℎ( ) is the larger of ( ) and have for all ≥ , 0 ≤ ( ) ≤ ℎ( ) and 0 ≤ ( ) ≤ ℎ( ). Adding these two inequalities yields 0 ≤ ( ) + ( ) ≤ 2ℎ( ), or

( ), we

equivalently 0 ≤ ( ( ) + ( )) ≤ ℎ( ), which shows that ℎ( ) = max( ( ), ( )) ≥ (with

=

in the definition of Θ).

( ( ) + ( )) for all



2. To show that ( + ) = Θ(

), we want to find constants

that 0 ≤ ≤( + ) ≤ for all Note that + ≤ +| | ≤2 when | | ≤ , and + ≥ −| | when | | ≤

≥ Thus, when



,

,

> 0 such

.

.

≥ 2| |,

0≤



Since

> 0, the inequality still holds when all parts are raised to the power

0≤(

) ≤ ( + ) ≤ (2 ) ,

0≤( ) Thus,

+

≤2 .

≤( + ) ≤2 =( ) ,

=2 ,

. = 2| | satisfy the definition.

:

3. (a) ( )=

−2 +1≤

exists one solution: Thus,

( )= (

, for all

>

,

>

,

= .

= 1, ).

(b) ( )=

−2 +1≥

= ,

exists one solution: Thus,

( ) = Ω(

, for all = 2.

).

(c) Let the running time be ( ). ( ) ≥ ( ) means that ( ) ≥ ( ) for some function ( ) in the set ( ). This statement holds for any running time ( ), since the function ( ) = 0 for all is in ( ), and running times are always nonnegative. Thus, the statement tells us nothing about the running time.