COMP 1001: Introduction to Computers for Arts and Social Sciences Sorting Algorithms Wednesday, June 1, 2011
COMP 1001: Introduction to Computers for Arts and Social Sciences How do you sort when you can only compare two things?
COMP 1001: Introduction to Computers for Arts and Social Sciences Sorting Demo /bottlesort/
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?
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?
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
COMP 1001: Introduction to Computers for Arts and Social Sciences Selection Sort Dance Ns4TPTC8whw
COMP 1001: Introduction to Computers for Arts and Social Sciences Selection Sort Demo algorithms.com/selection-sort
COMP 1001: Introduction to Computers for Arts and Social Sciences Selection Sort Demo (II) ukundan/dsal/SSort.html
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
COMP 1001: Introduction to Computers for Arts and Social Sciences Insertion Sort Dance OalU379l3U
COMP 1001: Introduction to Computers for Arts and Social Sciences Insertion Sort Demo algorithms.com/insertion-sort
COMP 1001: Introduction to Computers for Arts and Social Sciences Quick Sort
COMP 1001: Introduction to Computers for Arts and Social Sciences Quick Sort Demo algorithms.com/quick-sort
COMP 1001: Introduction to Computers for Arts and Social Sciences Quicksort Demo (II) ukundan/dsal/QSort.html
COMP 1001: Introduction to Computers for Arts and Social Sciences Quicksorting a Stack of Graded Papers Syr8o8jjwM
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?
COMP 1001: Introduction to Computers for Arts and Social Sciences Selection Sort vs. Quicksort VMKXKoGu_Y