1 / 9

Big O

Big O. Some definitions. Algorithm : A computable set of steps to achieve a desired result. Efficiency : The amount of resources used to find an answer. Algorithm Cost : How much power, resources and time the algorithm takes to run. Big O Notation.

Télécharger la présentation

Big O

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Big O

  2. Some definitions • Algorithm: A computable set of steps to achieve a desired result. • Efficiency: The amount of resources used to find an answer. • Algorithm Cost: How much power, resources and time the algorithm takes to run.

  3. Big O Notation • A theoretical measure of the execution of an algorithm given the problem size n (which is usually the number of items in the input)

  4. Asymptotic Analysis • An asymptote • A curve approaches, but never quite touches, its asymptote • We only care about the largest orders of magnitude

  5. Asymptotic analysis If we reduce the equation to the biggest term, we end up with a function representing the "asymptotic bound" of the equation. This kind of analysis is known as asymptotic analysis.

  6. Practical analysis • Algorithm 1 runs in 10 seconds on computer 1 • Algorithm 2 runs in 20 seconds on computer 2 • Which is the more efficient algorithm? • What if they are running on the same machine? Input size, implementation dependency and platform dependency.

  7. Typical Big O values • O(1) smart sum • O(log n) binary search • O(n) naïve sum • O(n log n) quick sort • O(nc) insertion sort • O(cn) Towers of Hanoi • O(n!) Travelling salesman

  8. Bubble Sort Outer loop, works repeatedly down the list When an unsorted pair is found, it is swapped until there are no more swaps

  9. Bubble Sort

More Related