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

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

CIS3023: Programming Fundamentals for CIS Majors II Summer 2010 Ganesh Viswanathan Sorti ng Course Lecture Slides 24 May 2010 “The real focus here is bringing some sort of order.” --Janet Hubbell

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

View Full Document
Sorting 1. Rearrange a[0], a[1], …, a[n-1] into ascending order. 1. When done, a[0] <= a[1] <= … <= a[n-1] 1. a[0], a[1],…a[n] could be integers, doubles, characters, or objects
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.

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

View Full Document
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
Selection Sort Algorithm (Cont’d) Figure 1: An array of 10 elements Figure 2: Smallest element of unsorted array

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

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

## This note was uploaded on 05/27/2011 for the course CIS 3023 taught by Professor Dobbins during the Summer '08 term at University of Florida.

### Page1 / 15

Sorting - CIS3023 Programming Fundamentals for CIS Majors...

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

View Full Document
Ask a homework question - tutors are online