Download presentation
Presentation is loading. Please wait.
Published byQuentin Logan Modified over 9 years ago
1
COMP 1001: Introduction to Computers for Arts and Social Sciences Sorting Algorithms Wednesday, June 1, 2011
2
COMP 1001: Introduction to Computers for Arts and Social Sciences How do you sort when you can only compare two things?
3
COMP 1001: Introduction to Computers for Arts and Social Sciences Sorting Demo http://gailcarmichael.com/processing /bottlesort/
4
COMP 1001: Introduction to Computers for Arts and Social Sciences Sort Part One: – Find the lightest bottle using the scale – What is the easiest way to do this?
5
COMP 1001: Introduction to Computers for Arts and Social Sciences Sort Part Two: – Choose three bottles at random – Sort them using the scale – What is the fewest number of comparisons you can do?
6
COMP 1001: Introduction to Computers for Arts and Social Sciences Sort Part Three: – Sort all the bottles from lightest to heaviest by repeatedly finding the lightest bottle that’s left, and moving it into the sorted list at the top – This is known as Selection Sort
7
COMP 1001: Introduction to Computers for Arts and Social Sciences Selection Sort Dance http://www.youtube.com/watch?v= Ns4TPTC8whw
8
COMP 1001: Introduction to Computers for Arts and Social Sciences Selection Sort Demo http://www.sorting- algorithms.com/selection-sort
9
COMP 1001: Introduction to Computers for Arts and Social Sciences Selection Sort Demo (II) http://www.cosc.canterbury.ac.nz/m ukundan/dsal/SSort.html
10
COMP 1001: Introduction to Computers for Arts and Social Sciences Insertion Sort Take the next item in the unsorted list Insert it into the correct location in the sorted list – Do this by comparing the new item with each of the existing items until the correct place is found
11
COMP 1001: Introduction to Computers for Arts and Social Sciences Insertion Sort Dance http://www.youtube.com/watch?v=R OalU379l3U
12
COMP 1001: Introduction to Computers for Arts and Social Sciences Insertion Sort Demo http://www.sorting- algorithms.com/insertion-sort
13
COMP 1001: Introduction to Computers for Arts and Social Sciences Quick Sort
14
COMP 1001: Introduction to Computers for Arts and Social Sciences Quick Sort Demo http://www.sorting- algorithms.com/quick-sort
15
COMP 1001: Introduction to Computers for Arts and Social Sciences Quicksort Demo (II) http://www.cosc.canterbury.ac.nz/m ukundan/dsal/QSort.html
16
COMP 1001: Introduction to Computers for Arts and Social Sciences Quicksorting a Stack of Graded Papers http://www.youtube.com/watch?v=F Syr8o8jjwM
17
COMP 1001: Introduction to Computers for Arts and Social Sciences Efficiency Which sorting algorithm should be fastest in most cases? What would happen to quicksort if you picked the lightest bottle to arrange around each time?
18
COMP 1001: Introduction to Computers for Arts and Social Sciences Selection Sort vs. Quicksort http://www.youtube.com/watch?v=c VMKXKoGu_Y
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.