Advertisement
Advertisement

More Related Content

Slideshows for you(20)

Advertisement

More from Dimitris Psounis(20)

Advertisement

ΠΛΗ30 ΚΑΡΤΕΣ ΜΑΘΗΜΑΤΟΣ 2.2 (ΕΚΤΥΠΩΣΗ)

  1. !" #$# # #%$& '$ % • ($&$# $)* +,!$ '$)* , - .*/ ! • % (- 0 (- !& $)*/ " # $ • %#! $( *# , - !" #$#/ % & !1( 0 *# % 2 1 # #$ ' 2/ 34 ! 1 ' (- 0 2 56789:;;6! ' (#)$ <4 ! ' )$(- !!# !#' #' (- * %)*! ' (#)*$ =4 ,1 '$& *" #% ! 0>#! ' +#),$! ?4 *$ ($ * $ ' @% %! #$ 0 *( * A& # BCDEF! ' #)-$! +" #$# >#'&- !1( 0 *# % 2 1G 2 .! ' & #*# %( #!1( 0 -! / #*# %" ' ,'& 0 # $ *! / 1 $ - ' *0"% - ! 2! 3 0 # >! '& # ( % $) - $# *)$ 4! / #*#!& $ %( #!1( 0 5! 6 0 ! ! %($&$# @*) H 1 #/ / $) H 1 #/ : 5IJKLDMMI N B F procedure FibRec(n) if n=1 or n=2 then return 1 else a=FibRec(n-1) b=FibRec(n-2) c=a+b return c end if end procedure / 7 ) O / )8 9:;<)=>>: / • 6 .?) 2, 21,1 21 nff nn f nn n (1), 1 2 ( ) ( 1) ( 2) (1), 2 n n T n T n T n n N B N F procedure FibSeq(n) A[1]=1 A[2]=1 for i=3 to n A[i]=A[i-1]+A[i-2] end for return A[n] end procedure !1( 0 4 4: @#)$A+#)$ / B.B-B*B2 B. 4C* D- *C2 D* 2CE D2 EC- D4 -C* B ! 1 ' 2 $&- ,!$ '$&- !2'&-F/ / 1, 2,…, n Ai di-1 x di. O / 1 x 2 x … x n / • 6 & N B N F procedure DP_MatMult(A1,A2,…,An) for i=1 to n m[i,i]=0 end for for p=2 to n for i=2 to n-p+1 j=i+p-1 m[i,j]=+ for k=1 to j-1 q=M[i,k]+M[k+1,j]+d[i-1]*d[k]*d[j] if (q>M[i,j]) then M[i,j]=q , s[i,j]=k end for end for end for return M[1,n] end procedure !1( 0 4 4: @#)$A #)*$ jidddjkMkiM ji jiM jki jki ,],1[],[min ,0 ],[ 1 / FA=7>PQ GAH7P=Q B ! 1 ' 2 $&- ,!$ '$&- !2'&-F/ / X=x1x2x3…xn Y=y1y2…ym O / To / • 6 & N B F procedure LCS( , ) for i=1 to n : c[i,0]=0 for j=1 to m : c[0,j]=0 for i=1 to n for j=1 to m if xi=yj then c[i,j]=c[i-1,j-1]+1 else if (c[i-1,j]>c[i,j-1]) then c[i,j]=c[i-1,j] else c[i,j]=c[i,j-1] end if end if end for end for return c[n,m] end procedure !1( 0 4 4: @#)$A #),$ ji jin yxjijicjic yxjijic ji f 0,},],1[],1,[max{ 0,,1]1,1[ 00,0
  2. H / & # I . - ? )$ / / & JA#K L M$ O / @< & / • B& 1 1 #N: NO$ :PO # $ • 0 :A. ? )! 3 < = ? R (Q@R.SAS . S T - A - (Q@R-SA< . S T 4 A 4 - < T 2 A 5 (Q@R*SAR . S T .- A .- - < T U A V * R T 4 A .W (Q@R2SAT * R T E A .* 2 T T 4 A .2 (Q@R4SA3= ! " !1( 0 4 4: @#)$A #)T,$
Advertisement