Sorting - CIS3023: Programming Fundamentals for CIS Majors...

Info iconThis 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
Background image of page 1

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

View Full DocumentRight 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
Background 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.
Background image of page 3

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

View Full DocumentRight 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.
Background image of page 4
Selection Sort Algorithm (Cont’d) Figure 1: An array of 10 elements Figure 2: Smallest element of unsorted array
Background image of page 5

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

View Full DocumentRight Arrow Icon
Selection Sort Algorithm (Cont’d) Figure 3: Swap elements list[0] and list[7] Figure 4: Array after swapping list[0] and list[7]
Background image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 14

Sorting - CIS3023: Programming Fundamentals for CIS Majors...

This preview shows document pages 1 - 7. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online