That is we essentially count the number of steps involved in executing the

That is we essentially count the number of steps

This preview shows page 34 - 41 out of 78 pages.

That is, we essentially count the number of steps involved in executing the algorithm. An intuitive explanation of complexity analysis is the following. We caution you that our explanation is clearly an oversimplification, but it suffices for our purposes.
Complexity Analysis Given a certain input size, assuming that to process a single element takes one unit of time, how many units of time are involved in processing n elements of input?
Complexity Analysis
Complexity Analysis Now consider the three presented comparison-based sorting algorithms. For all, the outer loop has n steps, and for the inner loop the size of the list shrinks by one with each pass. So the first time it takes n steps, the next time n – 1, the next time n – 2, and so on. Thus, the number of steps is: n + (n – 1) + (n – 2) + ... + 3 + 2 = 2 + 3 + ... + (n – 2) + (n – 1) + n
Complexity Analysis
Searching Searching a list of names or numbers is another very common computer science task. There are many search algorithms, but the key in developing a search algorithm is to determine

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture