1 / 8

Selection Sort Method

Selection Sort Method. Joon Hee Lee August 12, 2012. What is Selection Sort?. Selection Sort is one of the many sorting algorithms Known for being a very simple method Although it is very simple, it has some performance advantages over more complex methods in certain cases.

ross-osborn
Download Presentation

Selection Sort Method

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. Selection Sort Method JoonHee Lee August 12, 2012

  2. What is Selection Sort?

  3. Selection Sort is one of the many sorting algorithms • Known for being a very simple method • Although it is very simple, it has some performance advantages over more complex methods in certain cases

  4. How Does It Work? • Loops through a list and performs these steps : • 1st: Finds the lowest value in the list • 2nd: Swaps the lowest value with the first value in the list • 3rd: Start this process from the second position and repeat

  5. Example: Selection Sort Credit: http://51051208.blogspot.com/ Credit: http://en.wikipedia.org/wiki/File:Selection-Sort-Animation.gif

  6. Running Time • Has a time complexity of O(n^2) • Worst Case Performance : O(n^2) • Best Case Performance : O(n^2) • Average Case Performance: O(n^2) Has to locate an item and then swap it. The more items in a list, the more time it will take.

  7. More/Less Efficient Cases • The Selection Sort method is often times an inefficient method to use as it takes a long time. • Case where it is more efficient: • Selection sort is usually faster with smaller array • Because no additional storage space is required, this method is preferred when you must sort in place or without additional space. • It is much slower when dealing with large arrays as this method has to loops through the entire list many times

  8. Example Selection Short Code Source: http://www.fredosaurus.com/notes-cpp/algorithms/sorting/selectionsort.html

More Related