1 / 11

Sorting Algorithms

Sorting Algorithms. Overview. Why is Sorting important? Sorting algorithms Comparing Sorting Algorithms. Why is Sorting important?. Computers often use large data sets Sorted data sets are easier to use Humans like sorted lists Our brains are comparison engines. Sorting algorithms.

rianna
Download Presentation

Sorting Algorithms

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. Sorting Algorithms

  2. Overview • Why is Sorting important? • Sorting algorithms • Comparing Sorting Algorithms

  3. Why is Sorting important? • Computers often use large data sets • Sorted data sets are easier to use • Humans like sorted lists • Our brains are comparison engines

  4. Sorting algorithms • Bubble Sort • Insertion sort • Merge Sort

  5. Bubble Sort • Slowest Algorithm (Bubble sort has worst-case and average complexity both О(n2)) • Moves through the array n-1 times

  6. Insertion Sort • Faster than Bubble Sort but still slow (The worst case insertion sort has a quadratic running time (i.e., O(n2)). • Works by moving an element to anywhere in the array it should be. • moves through the array once.

  7. Merge Sort • Better algorithm (O(n log n)) and can be done recursively • Break the array into small parts and sort. • When the small parts are reassembled, put them in order

  8. Comparing Sorting Algorithms • In CS we use O() notation (big 'O' notation) • It describes the limiting behavior of the function when the argument tends towards a particular value or infinity

  9. Some O() Notations

  10. What to Remember • There are many types of sorting algorithms • For small data sets, anything is probably quick enough • For large data sets, algorithm complexity becomes very important

  11. References • http://en.wikipedia.org/wiki/Bubble_sort • http://en.wikipedia.org/wiki/Insertion_sort • http://en.wikipedia.org/wiki/Merge_sort • http://en.wikipedia.org/wiki/Big_O_notation

More Related