Sorting - CIS3023 Programming Fundamentals for CIS Majors...

Info icon This preview shows pages 1–7. Sign up to view the full content.

View Full Document Right Arrow Icon
CIS3023: Programming Fundamentals for CIS Majors II Summer 2010 Ganesh Viswanathan Sorting Course Lecture Slides 24 May 2010 “The real focus here is bringing some sort of order.” --Janet Hubbell
Image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Sorting 1. Rearrange a[0], a[1], …, a[n-1] into ascending order. 2. When done, a[0] <= a[1] <= … <= a[n-1] 3. a[0], a[1],…a[n] could be integers, doubles, characters, or objects
Image of page 2
Sorting Algorithms 1. Selection-based Selection sort Heap Sort 2. Insertion-based Insertion Sort Shell Sort 3. Exchange-Based Bubble Sort Quick Sort 4. Merge-based Merge Sort All these are comparison-based sorting algorithms.
Image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Selection Sort Algorithm List is sorted by selecting a list element and moving it to its proper position. Algorithm finds position of smallest element and moves it to the top of unsorted portion of list. Repeats process above until entire list is sorted.
Image of page 4