# Legibilidade dos algoritmos A importAanCia de um algoritmo

## Transcrição

Legibilidade dos algoritmos A importAanCia de um algoritmo
```!#"\$&%('*+-) ,/. +103254 +7698 \$:%;<'=>\$ 692?8AB<@ C 2D6
EFHGJILKMONQPRMSFMOTVUJKXW7M;KZY[I\-U5I]Z^9UJK`a _ UIbdcJUJNecfTg\-U\-h*K[MObdY[IiUSY[IFW&U5\*IcDTV\7M
\-Ih-FjW-KUOGJK[MOFm MblMOk UnIm GdMO]oY[Uib*ILFpUiIL] a KZIcJIb-\-U-Pqb*ILFjUr\-IW-h-K[M;b-\-U-PsFiMO]t]TgF
FMObdY[Ib-\-U;uvU-w ExFyh-TeY[U\*Tg^oz m a TVN7]ZI{NVILF|-K[MOK}\-UJ]\-IY[MONV~-I]\-Ih-FW*KUJGJKMOFMIL] a KZTgY[U
~Mm ]ILTg]FIL]ZIL]M;YK7MOm ]wNILm F\-TV]Z]U-PDcMOm KTVMO]}cOILIL]tMFUf\*Tg a Msa _ MOk U^9ILTeYMIFh*FW*KU;u
GJKMOFMyblMOk UxI{m ^9ILTgY[MyWsINVU]IhMOhfY[UJKUJKZTVGJTgb7MON!PDFMO]]ZTVFW&UJKUJh*YK[MW&IL]]ZUdM*w
drDO7f:&D  O*`L*O (¡O¢`O£Q`L7¤?rDD¥
(7¡O`¦§¡(£<i7O¨
©SI]FU]ZIIL]]MO]XW-KIU a h-W7Msa _ UJk IL]XblM;k U¤IL]ZYLMOk UªW-KI]Ib?YIL]«?h7MOb-\-U]I>Im h*F¬IL]oY[hfu
\7M;b?YLP­IXm TVFWsUJKoYMObdYI®\-IL]ZILbdcJUONgcJIK|&UJb-]~MOm |*TgY[UO]\-IXW-KUJGOK[MOFMsa _ M;k U-w
¯\$&>\$ +-4 2D, ' + % +#6 2?8 9°R 6 0+7032-±
nNVILGOTV|-TgNVTV\-MO\-IAI}h-F²MONVGOUJKTeY[FUrI³m h-FM a MOKM a YILKLm ]ZYT a MFyh-TeY[UtTVFWsUOKZYM;b?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K! &K!'@ 1B:\$1(
'IG H \$(C"" @ \$(C"[email protected] /B J
\$(C" @#B B
K! &K!'@ B67#K!9\$157#K! -W KZUJGJK[M;FiM1M a TVFM1I]ZY7M m a UOKKIY[U-P³FiM;]Iªm \-Te^oz m a TgN­\-INVIKI\-IILbdY[Ib-\-IKLw W-KZUJGJKMOFiMMO|-MOT U¤I³m I]]ZIFIL]FUW-KUOGJK[MOFMIL] a KTeY[U»\-I³h*FiMFMOb-ILTgK[MFMOTV]qNgILG7z m cJILN!w
)#\$//&
(- '/!' 2+:\$<%&"\$.2+'+%
\$6%& "!:#('(-+#2 5&+'(&-+2 >1'&2&>?#2+' >"! &#K!#(.%'9 /( 9\$1': !&#K!#: &\$?2/'+%
E7
(1!&#2+',\$1'+%'E
<&(/!'.%&/2?'+-(&'\$ ,C1
'"% &'+%
,%&'9 /( 9\$1:
' -"
'&2.'I\$"!'.%
\$
C1
'"% &'+%
&\$,%
\$E>1'11#\$ +&( 2&1'(
'
'+' F 0F 0
9">&+
& '&2 2+'+% )2+'+%
%'+%
+0
2+'+%+ )2+'+%
,%'+%
+0
9 /( 9\$1' ) 9 #/(\$1' 0
2+
('@ 2+'+%
2+'+%
B
) (9>1'&,%
\$.2+'+%
&\$10
) 6
'& ?;+:+ \$<#\$ %&'+%
\$ >+'&2>?#2"'E K!&K!:' # /1 \$1' 0
\$1 @ 2"'+%
GIF
B5 @ 2+'+%
+IGEF
B
K! &#K!'@ (B
\$1(
'&
9 #/(\$1':G H \$(C"" @ \$(C"[email protected] 2+'+%
"B5J \$1C"[email protected] 2+'"%
+
B B
K! &#K!'@ 9 #(( \$+'
B
7#K!9\$1
7#K!
M;k UI Tg]ZYIh-FM^;UOm KFyh-NVMy\-IYILKZFTgb7MO\7MW7MOKM]ZI^ MOILKtUiMONgTVb-~-MOFIbdY[U\-I a U;u
FMOb-\-UO]LPFMO]h*FiM1cJIL«?h-IcJU a I5´ YILb-~-M IL] a UJNV~*TV\-U#h-FiM1^9UJKFM1\-I5^ MOILKiI]]ZI
MONgTVb-~-MOFIbdY[U-P h*YTVNVTgLI uM5]ZILFW-KI\-IFiMOb*ILTVKM a UJb-]ZTV]oY[ILbdYISb-UO]iMONgGJUJKZTgY[FUJ]w/UJK
I IFW*NVU-PJU a UJFMOb-\-U 2 \-UXMONgGJUJKZTgY[FU»M a TgFiMtWsUD\-ILKZT¼M»YILKA]ZTV\-U{I] a KTgYU{\-IM a UJK\-U
a UJFU]IGJh-TVbdYIM;NVTVb*~7MOFILbdY[
U @ 2"'+%
GIF
B5 @ 2+'+%
+IGEF
B
K! &K!'@ 1B
\$1('&
9 #(( \$+':G H:\$1C"" @ \$1C"[email protected] 2+'"%
+ B5J \$(C"[email protected] 2+'+%
+B B
K! &K!'@ #/1 \$1'
B
7#K!9\$1
\$1
»Ib-~?h-FM\7M;]A^9UJKFMO]M a TVFM5Im FiM;TV] a UJKKZIYM{UJhFMOTV]RNVILG-z m cJIN-\-UX«?h-ItM{UJh*Y[KM*w
EbdY[KZIYM;b?YU-P}h-FiMcOILª«?h-Iªh-FiM^9UJKZFiM I¤m I] a UJNV~-Tg\7M*P ILNVM\-IcOIS]ZILK a UOb-]Tg]ZY[IbdY[Iu
FILbdY[IXFMObdY[Tg\7Myb7MIL] a KTeYM\-UMONVGOUJKTeY[FU-w
L\$ 02 " + %-2D) , ' 2 2 2 2 "3% 2 \$ 2 UJNgUf«?h-IyW-MOKLI´ b?YIL]{IFI W*KIL]Z]LUJk I]\*I^9UJKFMiMiYUJKb-MOKFMOTV]tNVIG7z m cOILNRMiUJK\*ILF
\-IMº¸ c;MONVTVMsa _ M;k Uy\-UJ]UJW&ILKMO\-UJKZIL K] EG: /
*
IXm FiM;TV]­NgILG7z m cJILN ]IIL] a KTeYM\7M]IGJh-TVbdYI^9UJKZFiM&
@5
G
B5
@[email protected]
# B
*
B
{MFI]FMy^9UJKFM*P-MI W*KIL]Z]LMOk UiMO|7MOT U
H
6H .
DE
J E·
I«Dh*Tgc;MONVIbdY[I M
]ILGOh-TVbdY[IXI W*KIL]Z]LMOk U & |&ILFFMOTV]NVILG-z m cJIN ( @[email protected]
B H @ BEB D @:
J "B
RM;K[M a MO\-MªW-MOKLI´ b?YIL]ZIiMO|&ILKoY[Uª\-IcJI~7MºcJILKXh-F¬W7MOKLI´ bdY[IL]ZI\*Iy^9I a ~7MOFILbdYU-w bh-m FILKZU#\*I5W7MOKLIL´ bdY[I]I\-I5MO|&ILKZYh-K[M \-IcOI]IKiTVGOh7MONtMOU>bh*m FIKU \-I5W7M;KLIL´ bdYIL]I]
\-I^9I a ~7M;FIb?YU-w ILKZTg7«?h-IiMO] a UJKKZIL]ZWsUJb*\qIL´ b a T¼MO]ILbdY[KZIrUJ]W7MOKLIL´ bdY[I]IL]yYK[Msa _ MOb-\-U
NgTVb-~7M;] a UJb-I a Y[MOb-\-U a MO\7M1W7MOKM#\-IW7MOKLIL´ bdY[I]IL] & blMOk U b-U>MONVGJUOKTgYFU (w h-]ZU>\-I
I]W7M a UILbdY[KZI W-MOKLI´ b?YIL]ZIL]MO\ "M a ILbdY[I]¤YMOFy|³ILm F M "Zh-\7M b7MxNVIGJTV|*TVNVTg\7MO\-I¤\*Ih-FiM
I W*KIL]Z]LMOk U*w
, BEB @ I
H @ EJ#B.B
@[email protected] E
J/#B @
L \$ 0 2 ¯\$ , ' +7, ' 2  hfY[TVNgTVLMsa _ MOk Uª\-I a UJb*]ZYM;b?YIL]#I m h*m Y[TgNW7MOK[MSMSNgILGJTg|-TVNgTV\7MO\*IyI a UJb*:MO|*TVNVTg\7MO\-I\-I
h-F W-KUJGOK[MOFM*w ¸ UJb*]TV\*ILKIXU]IGJh-Tgb?YIW*KUJGJKMOFM
9">&+
&'&2 &'
+
'"& '
+2 ('@ &'+&B
'+ 'IG H/ ,\$/[email protected] '
+&B
K! &#K!'@'+& ' B
7#K!
]ZILGJh*TVbdY[IW-KUOGJK[MOFMyFUf\-Te a M;\-U I{m FiM;TV]­^;M m a TVN \*INgILKIXFUf\-Te a M;KLw
9">&+
>"/\$
9
&'&2 &'
+ '"& '
7#K!
+2 ('@ &'+&B
'+ 'IG H 9 /\$ [email protected] &'
+&B
K! &#K!'@'+& 'B
h*Y[KZUI ILFW-NVUFMOTV] a UJbdcDTVb a ILbdY[I(
9">&+
# ;19 E'" &'( ;1&& '&2I'+ &'( &
FFI%& ?
/F FI%&5& '&2
'+' <%& '1 F F
'+':>"/:%& ='1 F F 7#K!
!+%#('EG H \$"?!'5%#?; F F
7h MOb-\*U{IL]]ZIW-KUOGJK[MOFMW-KZI a TV][M;KR]IKFUD\-Te a MO\*UW7MOKM®NVTg\7MOK a UJFh-F²b®h-m FIKU
\-Te^9ILKZILbdY[I\-Ic;MONgUJKI]\-I\7M;\-UJ]LP:Y[UD\7MO]»MO]tU a UJKKLIL´ b a T¼MO]t\-I ½ \-IcOILFj]IKILb a UJbfu
YK[MO\7M;]RIFh-\7MO\7M;]LwAEF²h-F W-KUOGJK[MOFM»GOK[MOb-\*IOPJTg]]U»WsUD\-I³]ILK/Y[IL\*TVUJ]ZU®IW-KZUJW&ILb-]ZU
MILKZKUJ]w ¶ FFIm YUf\-UFMOTV]³^;M m a TgN IXFiM;TV] a UJb*tM;m cOILNXI{m h*Y[TgNVTgºMOK³h-FiM a UJb-]ZY[MObdY[(I 9">&+
>"\$
1+4 F F
#
;19 E'" &'( ;1&& '&2I'+ &'( &
1"4 I%& ?
1+4 I%&5& '&2
+-# ) /!#2 "0
'+' <%& '1/1+4:%
'+':>"/:%& ='1/1+4:%
!+%#('EG H \$"?!'5%#?;
1+4
7#K!  GOUJK[M*P«?h7MOb*\-U5UªYMOFMOb-~*UW*KI a TV]MOK]ZILKFyh-\7M;\-U-P]UJFILbdYIh-FMªNVTVb*~7M¤\-Iu
cOILK7Mm ]ILKFyh-\7MO\-M*PfTgb-\-IWsIb-\-ILbdYILFILbdY[I®\*Uyb®h-m FILKU\-ItcJILIL]«?h-I®IN¼M1Im h-]MO\7Mb-U
W-KZUJGJKMOFiM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