Professional Documents
Culture Documents
Analysis
• The obvious measure of an input is the number
of elements in the array: i.e. n
• The most executed operations are in the “for
Loop”
• There are two operations in loop’s body:
• the comparison and
• the assignment
•=
•=
The Worst Case
•= -
•=
•
Brute force algorithms –Example 1
-1)-(i+1)+1]
=
Selection Sort
• The selection Sort is a algorithm on all inputs.
• Note However that the number of key swaps is only
• Or more precisely, n-1(one comparison for each
repetition of the loop)
Example 2 – Buble sort
Example 2 – Buble sort
• The action of the algorithm on the list, 89, 45, 68, 90, 29, 34, 17
Example 2 – Buble sort
Complete the analysis of this algorithm!