1 / 19

Sequential Sorting

Sequential Sorting . Sean Lyn COP4800 February 5, 2008. A Lower Bound on Speed. The fastest any comparison based sort can sort a list is O(NlogN) The longest any comparison based sort should take is O(N²). Sorting Algorithms . Selection Sort Insertion Sort Bubble Sort Shell Sort

makaio
Download Presentation

Sequential Sorting

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. Sequential Sorting Sean Lyn COP4800 February 5, 2008

  2. A Lower Bound on Speed • The fastest any comparison based sort can sort a list is O(NlogN) • The longest any comparison based sort should take is O(N²)

  3. Sorting Algorithms • Selection Sort • Insertion Sort • Bubble Sort • Shell Sort • Bucket Sort • Radix Sort • Quick Sort • Merge Sort – not covered • Heap Sort – not covered

  4. Selection Sort • “Selects” the smallest element • Find the smallest element • Put that element at the beginning • Repeat • Speed: O(N²)

  5. Insertion Sort • “Inserts” the element into the right position • Start with the first element • Insert the next element into the current list in the right position • Repeat • Speed: O(N²)

  6. Bubble Sort • Compare the first two elements • Put them in order • Compare the second and third • Put them in order • Repeat this process • Speed: O(N²)

  7. Shell Sort • Sort the kth element of every nth set of elements where k goes from 1 to n • Repeat the process on (n-1) until n=1 • n <= size/2 • Speed: up to O(N^(7/6))

  8. n=3

  9. Bucket Sort • Put the elements into “buckets” of smaller denominations based on their most significant digits • Repeat on each bucket • Speed: O(N) – varies due to the bound of the digits

  10. Numbers are bound from 1 to 29starting with: 5 2 19 22 25 7 3 16

  11. Radix Sort • Sort the array based on the least significant digit • Sort the array based on the next least significant digit • Repeat until the array is sorted • Speed: O(N) – varies depending on the bound of the digits

  12. Quick Sort • Pick a pivot • Put all numbers lower than the pivot to the left of it and all numbers higher to the right • Repeat on the smaller arrays until only 1 element remains • Speed: O(NlogN) (average)

  13. The fastest any comparison based sort can sort a list is O(NlogN) • The longest any comparison based sort should take is O(N²) • Selection Sort – O(N²) • Insertion Sort – O(N²) • Bubble Sort – O(N²) • Shell Sort – O(N^(7/6)) • Bucket Sort – O(N) - depends • Radix Sort – O(N) - depends • Quick Sort – O(NlogN) - average

  14. Works Cited • Dewdney, A. The New Turing Omnibus. New York: Computer Science Press, 1989. • Douglass, Ben. Computer Science 2. UCF, 2006. • Weiss, Mark. Data Structures and Problem Solving Using Java. Boston: Pearson Education, Inc, 2006.

More Related