of 33

• Author

dimitris-psounis
• Category

## Documents

• view

14

0

Embed Size (px)

description

ΠΛΗ30 ΜΑΘΗΜΑ 1.5

### Transcript of ΠΛΗ30 ΜΑΘΗΜΑ 1.5

• 30 1:

1.5: T(n)=aT(n-b)+f(n)

T(n)=T(n/a)+T(n/b)+f(n) T(n)=T(n/a)+T(n/b)+f(n)

• .

B.

1. T(n)=aT(n-b)+c

1.

2. T(n)=T(n-1)+f(n)

1.

2 , 30, 1.5: T(n)=T(n/a)+T(n/b)+f(n) T(n)=aT(n-b)+f(n)

3. T(n)=T(n/a)+T(n/b)+f(n)

1.

2.

3. .3.6

.

• .

:

3.6 T(n)=T(n/a)+T(n/b)+f(n) T(n)=T(n-1)+f(n)

3 , 30, 1.5: T(n)=T(n/a)+T(n/b)+f(n) T(n)=aT(n-b)+f(n)

T(n)=T(n/a)+T(n/b)+f(n) T(n)=aT(n-b)+c

T(n)=T(n/a)+T(n/b)+f(n)

• B. T(n)=aT(n-b)+f(n)

4 , 30, 1.5: T(n)=T(n/a)+T(n/b)+f(n) T(n)=aT(n-b)+f(n)

H T(n)=aT(n-b)+f(n) .

:

f(n)=c, T(n)=aT(n-b)+c

..

a=1, T(n)=T(n-b)+f(n)

.

a, b, f(n) .

• . 1. T(n)=aT(n-b)+c

5 , 30, 1.5: T(n)=T(n/a)+T(n/b)+f(n) T(n)=aT(n-b)+f(n)

T(n)=aT(n-b)+c

1. 3 ( )

2. k ( ( ) ....3...)( += bnTnT

( )+= )3. ( n0

k). .. n0=0 n/b

4. k 2.

5. .

( ) .......)( += kbnTnT

0nkbn =

• B. 1. T(n)=aT(n-b)+c1. ( 1: 3 )

6 , 30, 1.5: T(n)=T(n/a)+T(n/b)+f(n) T(n)=aT(n-b)+f(n)

1 3 .

: :

:

( )

=

>+=

0,10,225)(

n

nnTnT

:

( )( )[ ] ( )( )[ ] ( ) 22525652252655

2254522455225)(

232

2

+++=+++=

++=++=

+=

nTnTnTnT

nTnT

• B. 1. T(n)=aT(n-b)+c1. ( 2: k)

7 , 30, 1.5: T(n)=T(n/a)+T(n/b)+f(n) T(n)=aT(n-b)+f(n)

2 k (

()

( ) .......)( += kbnTnT

( )...

2252565)( 23==

=+++= nTnT

( ) 22525...2525...

21 +++++=

==

kk knT

• B. 1. T(n)=aT(n-b)+c1. ( 3: k)

8 , 30, 1.5: T(n)=T(n/a)+T(n/b)+f(n) T(n)=aT(n-b)+f(n)

( n0 k).

()

0nkbn =

()

2/2

02

nkknkn

=

=

=

• B. 1. T(n)=aT(n-b)+c1. ( 4: k)

9 , 30, 1.5: T(n)=T(n/a)+T(n/b)+f(n) T(n)=aT(n-b)+f(n)

k 2. .

()

k=n/2 (n) :( )

22525...25522525...2505)(

212/2/

212/2/

+++++=

+++++=

nn

nn TnT

• B. 1. T(n)=aT(n-b)+c1. ( 5: )

10 , 30, 1.5: T(n)=T(n/a)+T(n/b)+f(n) T(n)=aT(n-b)+f(n)

:

()

=

+

=

n

i

ni

x

xx

0

1

11

k=n/2 (n) :

5,055,1)15(5,05

151525

525

]5...551[25]25...25252[5

22525...255)(

2/

2/2/

112/2/

12/

02/

12/22/

12/22/

212/2/

=

=+=

=

+=

=+=

=+++++=

=+++++=

=+++++=

+

=

n

nn

nn

n

iin

nn

nn

nnnT

• . 2. T(n)=T(n-b)+f(n)

11 , 30, 1.5: T(n)=T(n/a)+T(n/b)+f(n) T(n)=aT(n-b)+f(n)

T(n)=T(n-1)+f(n)

1. T(n), T(n-1),

2.

3.

• B. 2. T(n)=aT(n-b)+c1. ( 1: )

12 , 30, 1.5: T(n)=T(n/a)+T(n/b)+f(n) T(n)=aT(n-b)+f(n)

1 T(n) T(n0) n0 : :

:

( )1 3 , 0( )1, 0T n n n

T nn

+ >=

=:

1)0(13)0()1(23)1()2(

...

)2(3)3()2()1(3)2()1(

3)1()(

=

+=

+=

+=

+=

+=

TTTTT

nnTnTnnTnT

nnTnT

• B. 2. T(n)=aT(n-b)+c1. ( 2: )

13 , 30, 1.5: T(n)=T(n/a)+T(n/b)+f(n) T(n)=aT(n-b)+f(n)

2 :

3)1()( += nnTnT

1)0(13)0()1(23)1()2(

...

)2(3)3()2()1(3)2()1(

3)1()(

=

+=

+=

+=

+=

+=

TTTTT

nnTnTnnTnT

nnTnT

)(+

11323...)2(3)1(33)( ++++++= nnnnT

• B. 2. T(n)=aT(n-b)+c1. ( 3: )

14 , 30, 1.5: T(n)=T(n/a)+T(n/b)+f(n) T(n)=aT(n-b)+f(n)

3 . :

=

+=

n

i

nni1 2

)1(

=

++=

n

i

nnni1

2

6)12)(1(

=

+=n

i

kk ni1

1)(( )

()

15,15,12

)1(3131

])1()2(...21[313)1(3)2(3...23131

11323...)2(3)1(33)(

2

1

++=

=

++=+=

++++++=

++++++=

++++++=

=

nn

nni

nnn

nnn

nnnnT

n

i

• B. T(n)=T(n/a)+T(n/b)+f(n)

15 , 30, 1.5: T(n)=T(n/a)+T(n/b)+f(n) T(n)=aT(n-b)+f(n)

H T(n)=T(n/a)+T(n/b)+f(n) :

3.6 ( )

( )

111 +ba

111 >+ba

( )

, !

1>+ba

• . 3. T(n)=T(n/a)+T(n/b)+f(n)

16 , 30, 1.5: T(n)=T(n/a)+T(n/b)+f(n) T(n)=aT(n-b)+f(n)

T(n)=T(n/a)+(n/b)+f(n)

1. 2 2. ( f(n))2. ( f(n))3. ( )4. ( logcn c

a,b)5. T(n)=

• B. 3. T(n)=T(n/a)+T(n/b)+f(n)1. ( 1: 2 )

17 , 30, 1.5: T(n)=T(n/a)+T(n/b)+f(n) T(n)=aT(n-b)+f(n)

1 ( ).

: :

=

>+

+

=

1,1

1,32)(

n

nnnTnT

nT

:

=1,1 n

)(nT

2nT

3nT

4nT 3963

2642

32)(

nnTnTnT

nnTnTnT

nnTnTnT

+

+

=

+

+

=

+

+

=

6nT

6nT

9nT

N N N NO O O O

• B. 3. T(n)=T(n/a)+T(n/b)+f(n)1. ( 2: )

18 , 30, 1.5: T(n)=T(n/a)+T(n/b)+f(n) T(n)=aT(n-b)+f(n)

2 ( f(n) )

()

)(nT

2nT

3nT

4nT

6nT

6nT

9nT

n

2n

3n

4n

6n

6n

9n 3963

2642

32)(

nnTnTnT

nnTnTnT

nnTnTnT

+

+

=

+

+

=

+

+

=

N N N NO O O O

• B. 3. T(n)=T(n/a)+T(n/b)+f(n)1. ( 3: )

19 , 30, 1.5: T(n)=T(n/a)+T(n/b)+f(n) T(n)=aT(n-b)+f(n)

3 . .

i.()

)(nT

2nT

3nT

4nT

6nT

6nT

9nT

n

2n

3n

4n

6n

6n

9n

0: n

1:6

56

26

332

nnnnn=+=+

2: 22

65

...

9664nnnnn

==+++

i iin

65

• B. 3. T(n)=T(n/a)+T(n/b)+f(n)1. ( 4: )

20 , 30, 1.5: T(n)=T(n/a)+T(n/b)+f(n) T(n)=aT(n-b)+f(n)

4 . n/a kai n/b n0, n/min{a,b}=n0

c (. c=min{a,b} ) logcn. (. c=min{a,b} ) logcn.

()

log2n

• B. 2. T(n)=T(n/a)+T(n/b)+f(n)1. ( 5: )

21 , 30, 1.5: T(n)=T(n/a)+T(n/b)+f(n) T(n)=aT(n-b)+f(n)

5 . .

:

()

=

+

=

n

i

ni

x

xx

0

1

11

:

( )

log log

0 0

log 1

log

0

log 1

5( ) 56 6

5 15 656 16

6 0,83 6

in ni

i ii i

n

in

i

n

nT n n

n n

n n

= =

+

=

+

= = =

= = =

=

• . 3. T(n)=T(n/a)+T(n/b)+f(n)2.

22 , 30, 1.5: T(n)=T(n/a)+T(n/b)+f(n) T(n)=aT(n-b)+f(n)

T(n)=T(n/a)+(n/b)+f(n)

1. a b .

2. a b .

3. .

• . 3. T(n)=T(n/a)+T(n/b)+f(n)2.

23 , 30, 1.5: T(n)=T(n/a)+T(n/b)+f(n) T(n)=aT(n-b)+f(n)

.

a,b a,b: : 2

43)( nnTnTnT +

+

=

: :

:

2( ) 23n

n n = +

2( ) 24n

n n = +

• . 3. T(n)=T(n/a)+T(n/b)+f(n)2. (1. )

24 , 30, 1.5: T(n)=T(n/a)+T(n/b)+f(n) T(n)=aT(n-b)+f(n)

.

2

32)( nnAnA +

=

63,02loglog,)(,3,2 2 ===== annfba:: >0 c

• . 3. T(n)=T(n/a)+T(n/b)+f(n)2. (2. )

25 , 30, 1.5: T(n)=T(n/a)+T(n/b)+f(n) T(n)=aT(n-b)+f(n)

.

2

42)( nnKnK +

=

5,02loglog,)(,4,2 2 ===== annfba:: >0 c

• . 3. T(n)=T(n/a)+T(n/b)+f(n)2. (3. /)

26 , 30, 1.5: T(n)=T(n/a)+T(n/b)+f(n) T(n)=aT(n-b)+f(n)

,

.

(...) :

)()( 2nnT =

, !

:

)()( 2nnT =

)()( 2nnT =

)()( 2nnT =

• . 3. T(n)=T(n/a)+T(n/b)+f(n)3. 3.6

27 , 30, 1.5: T(n)=T(n/a)+T(n/b)+f(n) T(n)=aT(n-b)+f(n)

T(n)=T(n/a)+(n/b)+f(n) 3.6 3.6

ba11

+

1.

2.

3. 3.6

ba+

111 +ba

• B. 3. T(n)=T(n/a)+T(n/b)+f(n)3. 3.6 ()

28 , 30, 1.5: T(n)=T(n/a)+T(n/b)+f(n) T(n)=aT(n-b)+f(n)

3.6 .

: :

:

2

43)( nnTnTnT +

+

=

:: .3.6 :

: :

:: .3.6 :

1127

123

124

41

31

• . 1 :

29 , 30, 1.5: T(n)=T(n/a)+T(n/b)+f(n) T(n)=aT(n-b)+f(n)

( )4 3 5, 0) ( )0, 0T n n

A T nn

+ >=

=

2

0, 0

( 1) 2 , 0) ( )1, 0

n

T n n nB T n

n

=

+ >=

=

• . 2

:

30 , 30, 1.5: T(n)=T(n/a)+T(n/b)+f(n) T(n)=aT(n-b)+f(n)

=

>+

+

=

1,1

1,43)()

2

n

nnnTnT

nTA

=

>+

+

=

=

1,1

1,3

23)()

1,1

n

nnnTnT

nTB

n

• . 3

31 , 30, 1.5: T(n)=T(n/a)+T(n/b)+f(n) T(n)=aT(n-b)+f(n)

2

32

2)( nnTnTnT +

+

=

• . 4

32 , 30, 1.5: T(n)=T(n/a)+T(n/b)+f(n) T(n)=aT(n-b)+f(n)

log44

3)() nnTnTnTA +

+

=

2

3

232)()

652)()

nnTnTnTC

nnTnTnTB

+

+

=

+

+

=

• . 5 .

(A1) n, n/3 n3.

33 , 30, 1.5: T(n)=T(n/a)+T(n/b)+f(n) T(n)=aT(n-b)+f(n)

(A2) n, n/2 n.

(A3) n-1 n3.

, .

: =

=n

ini

1

43 )(