100%(1)1 out of 1 people found this document helpful
This preview shows page 1 - 10 out of 56 pages.
&6(°±±²$lgorithms,ntroduction to $lgorithms
$lgorithm 'efinition• $ finite set of statements that guarantees an optimal solution infinite interval of time• $lgorithmic thinking and problem solving skill are vital in makingefficient solutions³• 7he (nglish word ´$/*25,7+0´ derives from the /atin word $/°$/°.+:$5,=0,’6 name³ +e developed the concept of analgorithm in 0athematicsµ and thus sometimes being called the“*randfather of &omputer 6cience´³±
*lance of $lgorithm• $n algorithm is a finite set of instructions or logicµ written in orderµto accomplish a certain predefined task³• $lgorithm is not the complete code or program• &an be expressed either as an informal high level description aspseudocode or using a flowchart³¶
$lgorithm 6pecifications• Input±(very $lgorithm must take zero or more number of input values fromexternal³• Output±(very $lgorithm must produce an output as result³• +**Definiteness°(very statement·instruction in an algorithm must be clear andunambiguous ¸only one interpretation¹• ,,Finiteness±)or all different casesµ the algorithm must produce result within afinite number of steps³• ,++Effectiveness±(very ,nstruction must be basic enough to be carried out and italso must be feasible³º
*ood $lgorithms"• 5un in less time• &onsume less memory%ut computational resources ¸time complexity¹ usually important»
¼$nalyzing $lgorithms•3redict the amount of resources required½•memory½ how much space is needed%•computational time½ how fast the algorithm runs%•)$&7½ running time grows with the size of the input•,nput size ¸number of elements in the input¹–6ize of an arrayµ polynomial degreeµ ¾ of elements in a matrixµ ¾ of bits in the binaryrepresentation of the inputµ vertices and edges in a graph+**Def%! 5unning time (4 the number of primitive operations ±steps° executed before termination–$rithmetic operations ¸¿µ °µ À¹µ data movementµ controlµ decision making ¸NOK± \]\MNOQRJ¹µcomparison
Â7ypical 5unning 7ime )unctions• ² ¸constant running time¹½– ,nstructions are executed once or a few times• log1 ¸logarithmic¹– $ big problem is solved by cutting the original problem in smaller sizesµ by a constantfraction at each step• 1 ¸linear¹– $ small amount of processing is done on each input element• 1 log1– $ problem is solved by dividing it into smaller problemsµ solving them independently andcombining the solution
Ã7ypical 5unning 7ime )unctions• 1±¸quadratic¹– 7ypical for algorithms that process all pairs of data items ¸double nested loops¹• 1¶¸cubic¹– 3rocessing of triples of data ¸triple nested loops¹• 1.