SlideServe
Menu
Préférences
© SlideServe · v2026

Algorithm Efficiency

ocean avatar
10 diapositives · 334 Views · Sep 01, 2014

Algorithm Efficiency. Algorithm efficiency A function of the number of elements to be processed f(n)=efficiency If a function is linear – that is, if it contains no loop – then its efficiency is a functions of the number of instructions it contains.

Algorithm Efficiency - slide 1
01 / 10Algorithm Efficiency
1 / 17

Télécharger la présentation

Algorithm Efficiency
Une image / un lien ci-dessous est fourni (tel quel) pour télécharger la présentation

Politique de téléchargement : le contenu du site vous est fourni TEL QUEL pour votre information et votre usage personnel ; il ne peut être vendu, concédé sous licence ni partagé sur d’autres sites sans l’accord de son auteur.Le contenu vous est fourni TEL QUEL, pour votre information et votre usage personnel uniquement. Téléchargez la présentation en cliquant sur ce lien. Lors du téléchargement, si vous ne parvenez pas à télécharger une présentation, l’éditeur a peut-être supprimé le fichier de son serveur.Pendant le téléchargement, si vous ne parvenez pas à obtenir une présentation, le fichier a peut-être été supprimé par l’éditeur.

F I N

Plus de contenu associé

Transcription de la présentation
  1. Algorithm Efficiency • Algorithm efficiency • A function of the number of elements to be processed • f(n)=efficiency • If a function is linear – that is, if it contains no loop – then its efficiency is a functions of the number of instructions it contains. • On the other hand, functions that loop vary widely in their efficiency.

  2. Algorithm Efficiency • Linear loop n=1000 i=1 loop (i<=1000) application code i=i+1 end loop f(n)=n

  3. Algorithm Efficiency • Logarithmic loop • Multiply 2 iteration < 1000 i=1 loop (i<1000) application code i=i x 2 end loop f(n)= log2 n

  4. Algorithm Efficiency • Logarithmic loop • Divide 1000 /2 iteration >=1 i=1000 loop (i>=1) application code i=i / 2 end loop f(n)= log2 n

  5. Algorithm Efficiency • Nested loop • Iterations = inner loop iterations x outer loop iterations • Linear logarithmic i=1 loop (i<=10) j=1 loop (j<=10) application code j= j x 2 end loop i=i + 1 end loop 10 f(n)= n [log2 n] log2 10

  6. Algorithm Efficiency • Nested loop • Quadratic i=1 loop (i<=10) j=1 loop (j<=10) application code j= j +1 end loop i=i + 1 end loop 10 f(n)= n2 10

  7. Big-O Notation The simplification of efficiency is known as big-O analysis. We don’t need to determine the complete measure of efficiency, only the factor that determines the magnitude. This factor is the big-O, and expressed as O(n) – that is, on the order of n.

  8. Big-O Notation • The big O notation can be derived from f(n) using the following steps: • In each term, set the coefficient of the term to 1. • Keep the largest term in the function and discard the others. Terms are ranked from lowest to highest as shown below: Log2n n nlog2n n2 n3… nk 2n n!

  9. Big-O Notation • Example: • Calculate the big-O notation for: • f(n) = n [(n+1)/2] Solution: ½ n2 + ½ n (Remove the coefficient) n2 + n (keep the largest term) n2 So, the big-O notation is stated as O( f(n) ) = O(n2)

  10. Complexity analysis • The same problems can frequently be solved with algorithms that differ in efficiency. • To compare the efficiency of algorithms, a measure of the degree of difficulty of an algorithm called computational complexity was developed by JurisHartmains and Richard E. Stearns. • Computational complexity indicates how much effort is needed to apply an algorithm or how costly it is. • The two efficiency criteria: • Time • Space • The factor of time is usually more important than that of space. • To evaluate an algorithm’s efficiency, real time units such as microseconds and nanoseconds should not be used. • Logical unit that express a relationship between the size n of a file or an array and the amount of time t required to process the data should be used.