Download presentation

Presentation is loading. Please wait.

Published byTyler Thick Modified about 1 year ago

1
Introductory Algorithms Lecture 01: Sorting Algorithms April 8 th, 2009 Jonathan Tse Overview – Sorting Activity – Post Sort Discussion – Sorting Algorithms – Wrap Up

2
Sort Playing Cards Sorting Order – Sort into Suits Clubs, Diamonds, Hearts, Spades – Sort Suits A 2 3 4 5 6 7 8 9 10 J Q K Rules 4/8/092 Overview – Sorting Activity – Post Sort Discussion – Sorting Algorithms – Wrap Up Cards In HandCards On Table Sort AloneGroup AGroup B Sort TogetherGroup CGroup D

3
Post-Sort Discussion What was different about how you sorted? Which way was harder/more time consuming? Which way took up more physical space? Was one way clearly better than another? Was one way better in a given situation? 4/8/093 Overview – Sorting Activity – Post Sort Discussion – Sorting Algorithms – Wrap Up

4
Post-Sort Discussion Moving 1 Card == 1 Processor Action Memory Space == Physical Space Tradeoff Between: – Number of Processor Actions – Memory Space Used 4/8/094 Overview – Sorting Activity – Post Sort Discussion – Sorting Algorithms – Wrap Up

5
Insertion Sort 4/8/095 Overview – Sorting Activity – Post Sort Discussion – Sorting Algorithms – Wrap Up 17 22 45 18 12 Array Space Working Space 23

6
Insertion Sort 4/8/096 Overview – Sorting Activity – Post Sort Discussion – Sorting Algorithms – Wrap Up 17 22 45 18 12 Array Space Working Space 23

7
Insertion Sort 4/8/097 Overview – Sorting Activity – Post Sort Discussion – Sorting Algorithms – Wrap Up 17 23 22 45 18 12 Array Space Working Space 23

8
Insertion Sort 4/8/098 Overview – Sorting Activity – Post Sort Discussion – Sorting Algorithms – Wrap Up 23 17 22 45 18 12 Array Space Working Space 45

9
Insertion Sort 4/8/099 Overview – Sorting Activity – Post Sort Discussion – Sorting Algorithms – Wrap Up 23 17 22 45 18 12 Array Space Working Space 23 45 23

10
Insertion Sort 4/8/0910 Overview – Sorting Activity – Post Sort Discussion – Sorting Algorithms – Wrap Up 18 17 22 23 45 12 Array Space Working Space 17 23 18 45 17

11
Insertion Sort 4/8/0911 Overview – Sorting Activity – Post Sort Discussion – Sorting Algorithms – Wrap Up 17 12 22 18 23 45 Array Space Working Space 23 45 23

12
Insertion Sort 4/8/0912 Overview – Sorting Activity – Post Sort Discussion – Sorting Algorithms – Wrap Up 17 12 45 18 22 23 Done!

13
Selection Sort 4/8/0913 Overview – Sorting Activity – Post Sort Discussion – Sorting Algorithms – Wrap Up 17 23 22 45 18 12 Array Space Working Space

14
Selection Sort 4/8/0914 Overview – Sorting Activity – Post Sort Discussion – Sorting Algorithms – Wrap Up 17 23 22 45 18 12 Array Space Working Space 12

15
Selection Sort 4/8/0915 Overview – Sorting Activity – Post Sort Discussion – Sorting Algorithms – Wrap Up 17 12 22 45 18 23 Array Space Working Space 17

16
Selection Sort 4/8/0916 Overview – Sorting Activity – Post Sort Discussion – Sorting Algorithms – Wrap Up 17 12 22 45 18 23 Array Space Working Space 18

17
Selection Sort 4/8/0917 Overview – Sorting Activity – Post Sort Discussion – Sorting Algorithms – Wrap Up 17 12 22 18 45 23 Array Space Working Space 22

18
Selection Sort 4/8/0918 Overview – Sorting Activity – Post Sort Discussion – Sorting Algorithms – Wrap Up 17 12 45 18 22 23 Array Space Working Space 23

19
Selection Sort 4/8/0919 Overview – Sorting Activity – Post Sort Discussion – Sorting Algorithms – Wrap Up 17 12 45 18 22 23 45 Array Space Working Space

20
Selection Sort 4/8/0920 Overview – Sorting Activity – Post Sort Discussion – Sorting Algorithms – Wrap Up 17 12 45 18 22 23 Done!

21
Merge Sort 4/8/0921 Overview – Sorting Activity – Post Sort Discussion – Sorting Algorithms – Wrap Up 23 17 45 18 12 22 37 36 12 22 37 36 23 17 45 18 12 22 45 18 37 36 23 17 23 17 45 18 12 22 37 36 Array Space Working Space

22
Merge Sort 4/8/0922 Overview – Sorting Activity – Post Sort Discussion – Sorting Algorithms – Wrap Up 12 17 18 22 23 36 37 45 12 22 36 37 17 12 18 36 17 23 17 45 18 12 22 37 36 17 23 18 45 12 22 36 37 17 18 23 45 17 18 23 17 18 Done! Array Space Working Space

23
0 1 2 3 4 5 6 7 8 9 Radix Sort 4/8/0923 Overview – Sorting Activity – Post Sort Discussion – Sorting Algorithms – Wrap Up 17 23 22 45 18 12 36 37 23 17 45 18 12 22 37 36 00 10 20 30 40 50 60 70 80 90 23 17 45 18 12 22 37 36 17 45 18 12 22 37 36 23 Done! Working Space Array Space

24
Summary of Sorting Algorithms Insertion Sort Selection Sort Merge Sort Radix Sort 4/8/0924 Overview – Sorting Activity – Post Sort Discussion – Sorting Algorithms – Wrap Up

25
Wrap-Up Was there anything in particular you noticed about the algorithms? Is one better than the other? In what situation is one better than the other? How do we objectively compare these algorithms? 4/8/0925 Overview – Sorting Activity – Post Sort Discussion – Sorting Algorithms – Wrap Up

26
Wrap Up Is there some comparison metric? Can we quantify memory usage? What about execution time? Does the list to be sorted affect anything? Is there a worst case? 4/8/0926 Overview – Sorting Activity – Post Sort Discussion – Sorting Algorithms – Wrap Up

27
Next Time Standard Metrics for Algorithm Performance Worst Case Analysis 4/8/0927 Overview – Sorting Activity – Post Sort Discussion – Sorting Algorithms – Wrap Up

Similar presentations

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google