Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

of

ΠΛΗ30 ΜΑΘΗΜΑ 1.1 (4in1) Slide 1 ΠΛΗ30 ΜΑΘΗΜΑ 1.1 (4in1) Slide 2 ΠΛΗ30 ΜΑΘΗΜΑ 1.1 (4in1) Slide 3 ΠΛΗ30 ΜΑΘΗΜΑ 1.1 (4in1) Slide 4 ΠΛΗ30 ΜΑΘΗΜΑ 1.1 (4in1) Slide 5 ΠΛΗ30 ΜΑΘΗΜΑ 1.1 (4in1) Slide 6 ΠΛΗ30 ΜΑΘΗΜΑ 1.1 (4in1) Slide 7 ΠΛΗ30 ΜΑΘΗΜΑ 1.1 (4in1) Slide 8
Upcoming SlideShare
ΠΛΗ30 ΜΑΘΗΜΑ 1.1
Next
Download to read offline and view in fullscreen.

1 Like

Share

Download to read offline

ΠΛΗ30 ΜΑΘΗΜΑ 1.1 (4in1)

Download to read offline

.

Related Audiobooks

Free with a 30 day trial from Scribd

See all

ΠΛΗ30 ΜΑΘΗΜΑ 1.1 (4in1)

  1. 1. 30 1: 1.1: !"# $!"# $ % " & '!( & ! " # # $ ! # ! !" # $ % % # # $ ! # $ ! # & ' # ( ) ! # " * + , # - . - . !)*& ! % !& ! !" # $ % )#)+ ! ," ! )$& +- + ! .! *& & " & )! ) ! * & +# *" !&, +# " )! ) ! * & + *& !"# ! , )$& )!/ #0! + )! !& *" !& +# ! ( +"!& 1 )"*. )#)+ ! 2)#)+ ! 2 )! ! *& & " & )! ) ! * & + 3"% $ "! $ )#)+ ! (-) 2. +$"# 1. +# *" !& *" !& +# # ! )! ! %, )! +) (+ 1 )"*. $& +-%&: 13+ +# ! ! + ! 1 $ ( ! * )! ! )"!. % !&) + +# + " / & !" 1 $ . $ ( )$ 1 + # )! $"#0+ ! )! ! %& – 30 4+ ! ) " + # 1-! ! + ! 1 $ ()! )+ ! #0+ ( ! )"!. % !&) &! !" # $ % " + # 1-! ! + ! 1 $ ()! )+ ! #0+ ( ! )"!. % !&) : /,01 2 2 0 32 2 2 '( ) ' ! $ " '( * + ' ,+$ + ) - ! $ " +$# . # ' /% •[5, 8, 9, 11, 14] •[4,12,7,9] +$# . # /% •[5, 8, 9, 11, 14],11 •[3,6,9,14,17],12 #' 0123456718745 9:;;<38745 83<3=56718745 >34?38745 @:6=A8745 #' B613C483C4=D 961C4E83C4=D F) + ' [5, 8, 9, 11, 14] [4,7,9,12] F) + ' GH0 I JKL
  2. 2. 2. +$"# 2. +# *& *" !& 5 & *& *" !& +# # )! !)! +# + ! 3+ + & )" -+ & )! + + +# # % & )"! " !(, *)$&: + ! 1& +) 4 &: for, while, do…while + ! % % &: if…else if…else ! 1& 3 " & M! !" # $ % ! 1& 3 " & " 1& )" -+ & (*)$& ).3. +,-,*,/,mod) … 6 ( + + % ! + +- + +)* + % ) 2. +$"# 3. $& . # ! + )! * ! !"# ! 1. 6"! % ! ) ! * 6"+ 0* + 1 " %" ! + # & ! )* ! *& +# 1 & *" !&. 3" !)! % ! + 3"! % )! ) ! * 3+ "* +" & )+"#) $ &. / ! + + +# * $& )"1)+ )" !( + +# 3"! % )! ) ! * + *& !"# ! : N! !" # $ % !( + * : " 3"! %& )! ) ! * & & SelectionSort +# : " 3"! %& )! ) ! * & & LinearSearch +# : ! "# $ % ! ! !& ' # $ # ( ( & # ( ) ( )T n n= 2 ( ) 3T n n n= + 2. +$"# 3. $& . # ! + )! * ! !"# ! 1. 6"! % ! ) ! * ( *" !& LinearSearch) & !( + 1 ) " + ( *" !& " %& 0% & – Linear Search) O! !" # $ % procedure LinearSearch(A,x) for i=1 to n if (A[i]==x) 7)! A +# 1 & )# & n ! 3+#$ , ! !)!#! 0 !( + ! ! 3+#! x. ! ! 3+#! ."+ +# ) + & ) + 76 . return « » end if end for return « » end procedure 2. +$"# 3. $& . # ! + )! * ! !"# ! 1. 6"! % ! ) ! * ( *" !& LinearSearch) ) "3! "+ & "*)! ( ! + 3"! % )! ) ! * ! !"# ! : 3+ "* +" & )+"#) $ & ( % )* + ! *" !& + & )+" * +"+& 1& )" -+ &). ! + " 1 ! *" !, * ! ! 3+#! + ) "3+ ! )# , " ! )" -+ & +# : P! !" # $ % .1 & )+"#) $ & ( % )* + ! *" !& + & * +"+& 1& )" -+ &). ! + " 1 ! *" ! * ! ! 3+#! +# )" 1 ! )# , " ! )" -+ & +# : 1 & )+"#) $ & +# )"!3$" 1 1 ! !& & & )! ) ! * & ) +# ) ! % $ + ! 1 $ + * ! . !( + 1 ! ! ()! ( + & + +)* + % . 1 ( ) 1 n i T n n = = = ( ) 1T n =
  3. 3. 2. +$"# 3. $& . # ! + )! * ! !"# ! 1. 6"! % ! ) ! * ( *" !& SelectionSort) * 1 ) " + (! *" !& - * & SelectionSort) Q! !" # $ % procedure SelectionSort(A) for i=1 to n pos=i for j=i+1 to n if (A[j]<A[pos]) 7)! A +# 1 & ( - * !&) )# & n ! 3+#$ if (A[j]<A[pos]) pos=j end if end for temp=A[i]; A[i]=A[pos]; A[pos]=temp end for end procedure 2. +$"# 3. $& . # ! + )! * ! !"# ! 1. 6"! % ! ) ! * (O *" !& SelectionSort) 7 13! + 1 () ! )+"#) ! !) *" ! )"!& + 1 , * +# ! + + !( + .% -.% + )! " * ) + 1 + &. + ! "*)! * . # ! + )$& + ! " +# ! *" !&. .3. + +# ! ! [4 3 5 1 2] 13! + .% .% + 1 + : ! !" # $ % 1 2 3 4 5 1 2 3 4 52% 1: 2% 4: 4 3 5 1 2 1 2 3 4 5 1 3 5 4 2 1 2 3 4 5 1 2 5 4 3 1 2 3 4 5 2% 1: 2% 2: 2% 3: 2% 4: 2% 5: + !&: 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 2. +$"# 3. $& . # ! + )! * ! !"# ! 1. 6"! % ! ) ! * (O *" !& SelectionSort) 3+ "* +" & )+"#) $ &. 3+ "* +" )+"#) $ +# * ! *" !& + +3+#& 3$"% + & ( ! .% & if) * ."# + "* +"! ! 3+#! ( * . # + * ! )# & +# - ! 1 !& + / # ! + " ). * + ! *" !& + & +-%& )" -+ &: ! !" # $ % 1 1 ( ) [1 ( 2) 3] n n i j i T n = = + = + + =1 1 1 1 1 1 1 1 1 1 2 2 1 2 [4 2( 1)] [4 2( ( 1) 1)] [4 2( )] [4 2 2 ] 4 (2 ) (2 ) ( 1) 4 2 2 4 2 2 2 3 i j i n n i j i n i n i n i n n n i i i n i n i n i n i n i n n n n i n n n n = = + = = + = = = = = = = = + = = + − + + = = + − = = + − = = + − = + = + − = + − = = + 2. +$"# 3. $& . # ! + )! * ! !"# ! 1. 6"! % ! ) ! * (O *" !& SelectionSort) ( +" & )+"#) $ &. ( +" )+"#) $ +# * ! )# & +# % - ! 1 !& + (-! + " , !)* + + 3"+ 0+ # + 3 " & if. * + ! *" !& + & +-%& )" -+ &: ! !" # $ % ( ) [1 ( 1) 3] n n T n = + + =1 1 1 1 1 1 1 1 2 2 1 2 ( ) [1 ( 1) 3] [4 ( ( 1) 1)] [4 ] [4 ] 4 ( ) ( ) ( 1) 4 4 2 0.5 2.5 n n i j i n i n i n i n n n i i i n i T n n i n i n i n i n n n n i n n n n = = + = = = = = = = = + + = = + − + + = = + − = = + − = = + − = + = + − = + − = = +
  4. 4. 2. +$"# 3. $& . # ! + )! * ! !"# ! 2. ) $ % # 6"! %& ! ) ! * & )!"!( + ) " "% ! + * : )! ) ! * 3+ "* +" & )+"#) $ & & LinearSearch +# / & + ( +" )* )! ) ! * ( +" & )+"#) $ &. )! ) ! * 3+ "* +" & )+"#) $ & & SelectionSort +# )! ( ! )! ) ! * & ( +" & )+"#) $ &. ! !" # $ % "! + 1 ! ) !)! % ! + * # : " !$ ! & ! * " & ) ( ! & " ! & # + , - )' 2. +$"# 3. $& . # ! + )! * ! !"# ! 2. ) $ % # 6"! %& ! ) ! * & + 3"% $ ) " ) $: 1 + * : )! ) ! * & LinearSearch 3+ "* +" )+"#) $ : 53+ " )! ) ! * & : 8 ) $ : &! !" # $ % ( )n nΤ = )()( nn Θ=Τ8 ) $ : )! ) ! * & LinearSearch ( +" )+"#) $ : 53+ " )! ) ! * & : 8 ) $ : )! ) ! * & SelectionSort 3+ "* +" )+"#) $ : 53+ " )! ) ! * & : 8 ) $ : )! ) ! * & SelectionSort ( +" )+"#) $ : 53+ " )! ) ! * & : 8 ) $ : )()( nn Θ=Τ ( ) 1nΤ = )1()( Θ=Τ n 2 ( ) 3n n nΤ = + 2 ( ) 0.5 2.5n n nΤ = + )()( 2 nn Θ=Τ )()( 2 nn Θ=Τ 2. +$"# 3. $& . # ! + )! * ! !"# ! 2. ) $ % # 6"! %& ! ) ! * & $& * $& -1"! + )! !& +# ! 1 !& *"!& + *& "!# !&; 3(+ +-%& +" "3# & " % + & )! ) ! * &: *)! : M! !" # $ % *)! : +"1& +# " % + & )! + ) "3+ ! n. 3! +: ! " 1& +# " % + & & !"/%&: 7)! k +# +" >0 ! $ 1& +# " % + & & !"/%&: 7)! k +# +" >0 + 1& +# " % + & & !"/%&: 7)! a +# +" >1 )+"+ + 1& +# ! +-%& (! " % + &: + )()( k nn Θ=Τ )()( n an Θ=Τ )(log)( nn k Θ=Τ )!()( nn Θ=Τ )()( n nn Θ=Τ n nn <! ( ) (1)nΤ = Θ 2. +$"# 3. $& . # ! + )! * ! !"# ! 3. 6$" % ! ) ! * + )! +& +/ " ! 1& +# 3"% ! -1"! + )* +& 1 + & % & ) !( + 1 + ! !"# ! . & )+" ) + & 1& + " + )* +& + . 1& ) !( + 1 + ! !"# ! . N! !" # $ % "! !3%! 5 & )# & + 1 ! & n, +# n + . 1&. 3 3" !)! +# ! .! !& (.) 13! + # ) $ % + # ! 3 "! + 1 + & ! !"# ! .
  5. 5. 2. +$"# 3. $& . # ! + )! * ! !"# ! 3. 6$" % ! ) ! * ( *" !& Fibonacci) ! !( + + 1 ) " + : ! ! # Fibonacci !"#0+ $&: O! !" # $ % = = = 2,1 1,1 n n fn 9 + )! ! # ! + ! n-! * *"! & ! ! # & + 1 *" !. & !( + ! & )" ! & *"! & & ! ! # & >+ −− 2,21 nff nn n 1 2 3 4 5 6 7 8 9 10 1 1 2 3 5 8 13 21 34 55 ... 2. +$"# 3. $& . # ! + )! * ! !"# ! 3. 6$" % ! ) ! * ( *" !& Fibonacci) # !)!# )! ! !( ! n-! !( Fibonacci +# * ! : P! !" # $ % procedure Fibonacci(n) A[1]=1 A[2]=1 for i=3 to n A[i]=A[i-1]+A[i-2] + . 1& )! 3" !)! +# ! )"* " +# : n + . 1& ! )# A (! + . 1& n i +) & 3$" % )! ) ! * +# T(n)=n+2 ) $ T(n)= (n) A[i]=A[i-1]+A[i-2] end for return A[n] end procedure 2. +$"# 3. $& . # ! + )! * ! !"# ! 3. 6$" % ! ) ! * ( *" !& Fibonacci) )!"!( + ! + ( +" 3+#" & % &; Q! !" # $ % procedure Fibonacci(n) if (n=1) return 1 else if (n=2) return 1 else a=1 + . 1& )! 3" !)! +# ! )"* " +# : )1 + + . 1& i,n,a,b,c +) & 3$" % )! ) ! * +# T(n)=5 ) $ T(n)= (1) a=1 b=1 for (i=3 to n) c=a+b a=b b=c end for end if return c end procedure 2. +$"# 3. $& . # ! + )! * ! !"# ! 4. ( " !"# $ 5 )"*. )!"+# +# )* /!"+ !(& *" ! &. )!/ # ! + )! !& *" !& +# ( +"!&: )! ! #0! + ) $ % )! ) ! * ( % ! (.) ) 3+ "* +" )+"#) $ . ) 1 ! + ! *" ! )! 13+ "* +" )! ) ! * . ! !" # $ % ) 1 ! + ! *" ! )! 13+ "* +" )! ) ! * . +)* + % !( + )"!. % )! + + % + * : 4 ! 5 # 6 # ! # $ ! 5 # B613C483C4=D RS T U RS1T 961C4E83C4=D RS T U RS<7? 1T 9:;;<38745 RS1 T RS1 T RS1 T 0123456718745 RS1T U RS1 T 83<3=56718745 RS1 T RS1 T RS1 T >34?38745 RS1 <7?1T RS1 <7?1T RS1 <7?1T @:6=A8745 RS1 <7?1T RS1 <7?1T RS1 T
  6. 6. . + ! ! ! # % +$ 1. )! ! *& ! ) ! * & 1. + " % 13! + !3 % )"! 1 ! + & # ! 3+& )! ) ! * +&: ! !" # $ % .... )! ) ! * +# +2+ .... . + ! ! ! # % +$ 1. )! ! *& ! ) ! * & 2. )! ! *& & for 8 + for # + 1 "! + $ *" ! "3% ! for ) $ *" ! ! 1 !& ! for. .3.: ! !" # $ % . .: for (i=A to B) )! ) ! * +# 6"% / !( +-%& "!# : for (i=A to B) ... K ... end for = = B Ai KnT )( = +Α−Β= B Ai 11 = += n i nni 1 2/)1( = ++= n i nnni 1 2 6/)12)(1( = + − − = n i n i x x x 0 1 1 1 .:,1 σταθccc B Ai B Ai= = = == = +=+ n i n i n i BABA 11 1 )( . + ! ! ! # % +$ 1. )! ! *& ! ) ! * & 3. /$ 1 ! 2"*3! + + /$ 1 ! & ."*3! &, "!( + ! & # ! & * +& )! +# + 1 ) * ."*3!. .3.: ! !" # $ % for (i= to ) for (j=C to D) ... K ... )! ) ! * +# ... K ... end for end for ( ) B D i A j C T n K = = = . + ! ! ! # % +$ 2. .! *& (.) +- ! + ! (.) & " & )! ) ! * &, )"1)+ ! + & *)! +& +) +" 1& * +& 1 + 13! + « " » "!# . 5)+ +) 1 ! + ! 1 ! )* ! & *"! & ! "!# !&, ! + ! + ! (.) &! !" # $ % " +# 1. 2. "! !3% * ) +#/! ! +"1& )! +# )! ) 1 +& + ! & *"! & ! "!# !&. )()1()( 22 nnnnnn Θ=+=+=Τ )( 6 1 6 3 6 2 6 )12)(( 6 )12)(1( )( 323 2 nnnn nnnnnn n Θ=++= ++ = ++ =Τ
  7. 7. . + ! ! ! # % +$ 3. * +& +$ # +" +- $ % ! (.) 3 )"! () + ! )! ! * +$ . ! ! !( ! * +"+& * +& +$ " 0 : M! !" # $ % 0 1 1a a a = = 1 0.52 B x x x= = ( ) ( ) ( ) n n m n n m nm m m a a a a a = = =1 1 1/ 1/k k a a a a a a − − = = = B BA A x x= ( ) / / ( / ) m m m n m n m n m n m m m a a a a a a a a a b a b + − = = = = . % + & 8 * & 1 )! ! # + # ) $ % + # $ +- & " % +$ )! ) ! * &: N! !" # $ % 2 1 2 0 2 ( ) (2 1) ( ) 2 (2 1) ( ) 5 ( 4 ) log n n n f n n n n f n f n n n = + + = + = + +0 2 3 22 4 6 5 0.01 6 7 62 44 8 ( ) 5 ( 4 ) log ( ) (2 ) ( ) log ! 1000 14 ( ) 1000 4( ) 2 ( ) 4 n n n n n n f n n n f n n f n n n n f n n f n f n n n n = + + = + = + + + + = + = = + + . % + & 8 * & 2 )! ! # + " .% )! ) ! * ! ) " $ % !& : O! !" # $ % for i=1 to n for j=1 to n a=a+1 end for b=a+a*a end forend for . % + & 8 * & 3 )! ! # + " .% )! ) ! * ! ) " $ % !& : P! !" # $ % for i=1 to n a=a/2 for j=1 to n a=a*10 end for b=a+a*a/2b=a+a*a/2 for j=i+1 to n a=a+9 end for end for
  8. 8. . % + & / " ! % 1 +("+ ! + 3 ! " !( + 1 )# " * )!"+# !)! +# + +-%& "! # : Q! !" # $ % procedure minArray(A) min=A[1] for i=2 to nfor i=2 to n if (A[i]<min) min=A[i] end if end for end procedure . % + & / " ! % 1 1. 3+ "* +" )+"#) $ 1. )! ! # + " .% )! ) ! * 2. + # ) $ % + # & )! ) ! * & 2. ( +" )+"#) $ 1. )! ! # + " .% )! ) ! * ! !" # $ % 1. )! ! # + " .% )! ) ! * 2. + ) $ % + # & )! ) ! * & . % + & / " ! % 2 & 1 +"!& *" !& - * & +# ! *" !& - * & + + $ % (InsertionSort). " $ / # + !)!# ! !"# ! !( + 4+ ! : ! !" # $ % procedure InsertionSort(A) for i=2 to n for j=i-1 to 1 if (A[j]>A[j+1]) temp=A[j] A[j]=A[j+1] A[j+1]=temp else break end if end for end for end procedure . % + & / " ! % 2 1. + 1 + 1 "* ! )! ).3. ! [5 4 3 1 2] # + ) * )$& ! +(+ ! *" !&. 2. * + 13! + 3+ "* +" )+"#) $ & + 1 + & ! !"# ! ; 3. ! )! ) ! * & 3+ "* +" & )+"#) $ &; 4. + ) $ % + # & )! ) ! * & & 3+ "* +" & ! !" # $ % 4. + ) $ % + # & )! ) ! * & & 3+ "* +" & )+"#) $ &. 5. * + 13! + ( +" )+"#) $ & + 1 + & ! !"# ! ; 6. ! )! ) ! * & ( +" & )+"#) $ &; 7. + ) $ % + # & )! ) ! * & & ( +" & )+"#) $ &.
  • alexadros2

    Mar. 1, 2020

.

Views

Total views

12,135

On Slideshare

0

From embeds

0

Number of embeds

9,923

Actions

Downloads

272

Shares

0

Comments

0

Likes

1

×