200
Reflections of ADS2 2011

Reflections of ADS2 2011

  • Upload
    freya

  • View
    26

  • Download
    1

Embed Size (px)

DESCRIPTION

Reflections of ADS2 2011. “There has never been a better time to teach Computer Science” Patrick Prosser 2011. Course home page. course content. Course content. Course content. Course content. Aims & Objectives. Aims and objectives. - PowerPoint PPT Presentation

Citation preview

Page 1: Reflections of ADS2 2011

Reflections of ADS2 2011

Page 2: Reflections of ADS2 2011

“There has never been a better time to teach Computer Science”

Patrick Prosser 2011

Page 3: Reflections of ADS2 2011
Page 4: Reflections of ADS2 2011

Course home page

Page 5: Reflections of ADS2 2011

course content

Page 6: Reflections of ADS2 2011

Course content

Page 7: Reflections of ADS2 2011

Course content

Page 8: Reflections of ADS2 2011

Course content

Page 9: Reflections of ADS2 2011

Aims & Objectives

Page 10: Reflections of ADS2 2011

Aims and objectives

- Learn about algorithms and data structures in java (surprised?)- Implement algorithms and data structures- Apply algorithms and data structures

Page 11: Reflections of ADS2 2011

Ulterior motives

- To be scientific- To be an engineer- To be a mechanic- To appreciate beauty

- neat, tidy, small, simple, efficient, fast, …- To think critically

- Costs and benefits- To do experiments (wherever possible)- Use big data sets (where possible)- “Teach yourself programming in 10 years”- To have fun

Page 12: Reflections of ADS2 2011

We are always learning

Page 13: Reflections of ADS2 2011
Page 14: Reflections of ADS2 2011

exercises

Page 15: Reflections of ADS2 2011

exercises

5 exercises, 2 are assessed, plus a zero exercise and a challenge

Page 16: Reflections of ADS2 2011

exercises… for instance

In 2 parts, implement a circular queue then use this to implement a sorting algorithm.Readme files, slides, hints and tips, code stubs to get started.There is a Test program (always is), a marking program (compiled), and data setsMarking program is just a part of final mark

Page 17: Reflections of ADS2 2011

exercises… for instance

1st part of the exercise, code stub

Page 18: Reflections of ADS2 2011

exercises… for instance

1st part of the exercise, code stub

Page 19: Reflections of ADS2 2011

Experiments in the Lecture

Page 20: Reflections of ADS2 2011

Experiments on the bench (in lecture)

- The effect of the wrong data structure- Using the IMDB data sets at Robert Sedgewick’s

Page 21: Reflections of ADS2 2011

Experiments on the bench (in lecture)

- The effect of the wrong data structure- Using the IMDB data sets at Robert Sedgewick’s

Page 22: Reflections of ADS2 2011

Experiments on the bench (in lecture)

- The effect of the wrong data structure- Using the IMDB data sets at Robert Sedgewick’s

Not a small effort … for only a part of a lecture!

Page 23: Reflections of ADS2 2011

Experiments on the bench (in lecture)

On Recursion

A small effort … for a part of a lecture Perm, power set, H-tree, binary tree, …

Page 24: Reflections of ADS2 2011

Experiments on the bench (in lecture)The growth of functions

Part of a lecture: editing and running code, using gnuPlot in the class, going off-topic(i.e. general effect of exponential growth “what does 3% economic growth mean?”)

Page 25: Reflections of ADS2 2011

Experiments on the bench (in lecture)Binary search

A demo that shows how search proceeds

Using unixWords (about 400,000 words)

A small effort … for a very small part of a lecture!

Page 26: Reflections of ADS2 2011

Experiments on the bench (in lecture)Is Big-Oh all there is to it?

A considerable effort … for only part of a lecture

Page 27: Reflections of ADS2 2011

Experiments on the bench (in lecture)Binary Search Trees v AVL Trees

Hashing (different functions)

Etc …

Page 28: Reflections of ADS2 2011
Page 29: Reflections of ADS2 2011

The students have lapTops

Page 30: Reflections of ADS2 2011

lapTops in the lectures

Page 31: Reflections of ADS2 2011

Now that we have won the lottery, what shall we do about the begging letters?

lapTops in the lectures

Page 32: Reflections of ADS2 2011

We shall keep sending them

lapTops in the lectures

Page 33: Reflections of ADS2 2011

What should we do with student lapTops in the lecture theatre?

Page 34: Reflections of ADS2 2011
Page 35: Reflections of ADS2 2011

The lecture theatre

Page 36: Reflections of ADS2 2011

Boyd Orr Lecture Theatre 2

Page 37: Reflections of ADS2 2011

Boyd Orr Lecture Theatre 2

- 3 screens with 3 data projectors- 3 vizualisers- Internet connected pc- Desk top lapTop connection- Lectern/desk that goes up and down- Sound system- On the ground floor, near to toilets, hopping distance from SAWB

Page 38: Reflections of ADS2 2011

Boyd Orr Lecture Theatre 2

I love BO2

Page 39: Reflections of ADS2 2011

Boyd Orr Lecture Theatre 2

I love the smell of Napalm in the morning ….

Page 40: Reflections of ADS2 2011

Boyd Orr Lecture Theatre 2

I love the visualizers …

- To use instead of a black/white board- To put things underneath (such as bits of paper)- … or lego- ….or stuff

I use all of BO2

Page 41: Reflections of ADS2 2011

We videoed all the lectures

… and what happened?

Page 42: Reflections of ADS2 2011

We videoed all the lectures

Attendance fell (but hey, Stanford ended up with 20 physical students)

40% < 40%

Page 43: Reflections of ADS2 2011

attendance

Swipe that!

Page 44: Reflections of ADS2 2011

What about the students?

Page 45: Reflections of ADS2 2011

What about the students?

- Mostly good- Surprising number are excellent- Thanks to 1st year and 1st semester

Page 46: Reflections of ADS2 2011
Page 47: Reflections of ADS2 2011

The End

and yes

it was all my own work

Page 48: Reflections of ADS2 2011

… just me, and these people

Alice MillerDavid ManloveDavid WattTom KellyGeoffreyCiaranJeremy SingerPaul CockshottDavidAndrewAndy BrooksRob IrvingGethin NormanGail ReatKaren RenaudPeter NightingaleAndrea & ZoeStewart McNeil…

Page 49: Reflections of ADS2 2011

“This is the best time to teach CS”

Page 50: Reflections of ADS2 2011

An example, using sorting

Page 51: Reflections of ADS2 2011

Sorting, what’s that then?

Given a collection of data, get it into order …

Page 52: Reflections of ADS2 2011

Sorting, what’s that then?

Given a collection of data, get it into order …

9 2 6 0 4 3 2 7 5

This is NOT in order

Page 53: Reflections of ADS2 2011

Sorting, what’s that then?

Given a collection of data, get it into order …

0 2 3 4 5 6 7 9

This is IS in order

Page 54: Reflections of ADS2 2011

Sorting, what’s that then?

Given a collection of data, get it into order …

0 2 3 4 5 6 7 9

This is IS in order

It’s in ascending order

Page 55: Reflections of ADS2 2011

Sorting, what’s that then?

Sorting is the process of going from this

0 2 3 4 5 6 7 9

9 2 6 0 4 3 2 7 5

to that

Page 56: Reflections of ADS2 2011

Sorting, why bother?

9 2 6 0 4 3 2 7 5

Who cares?

You can find things quicker!

Page 57: Reflections of ADS2 2011

Sorting, why bother?

0 2 3 4 5 6 7 9

9 2 6 0 4 3 2 7 5

Who cares?

You can find things quicker!

Use “binary search” (or even linear search and stop early)

Page 58: Reflections of ADS2 2011

Some algorithms for sorting

• bubble sort• insertion sort• selection sort• shell sort• gnome sort• merge sort• quick sort• heap sort• radix sort• bead sort

sorting

Page 59: Reflections of ADS2 2011

Some algorithms for sorting

• bubble sort• insertion sort• selection sort• shell sort• gnome sort• merge sort• quick sort• heap sort• radix sort• bead sort

sorting

quadratic

Page 60: Reflections of ADS2 2011

Some algorithms for sorting

• bubble sort• insertion sort• selection sort• shell sort• gnome sort• merge sort• quick sort• heap sort• radix sort• bead sort

sorting

logarithmic

Page 61: Reflections of ADS2 2011

Some algorithms for sorting

• bubble sort• insertion sort• selection sort• shell sort• gnome sort• merge sort• quick sort• heap sort• radix sort• bead sort

sorting

linear

Page 62: Reflections of ADS2 2011

Some algorithms for sorting

• bubble sort• insertion sort• selection sort• shell sort• gnome sort• merge sort• quick sort• heap sort• radix sort• bead sort

sorting

Our example

Page 63: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

9 2 06 4 3 2 57

Example

Page 64: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

9 2 06 4 3 2 57

Example

compare

Page 65: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

2 9 06 4 3 2 57

Example

swap

Page 66: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

2 9 06 4 3 2 57

Example

compare

Page 67: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

2 6 09 4 3 2 57

Example

swap

Page 68: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

2 6 09 4 3 2 57

Example

compare

Page 69: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

2 6 90 4 3 2 57

Example

swap

Page 70: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

2 6 90 4 3 2 57

Example

compare

Page 71: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

2 6 40 9 3 2 57

Example

swap

Page 72: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

2 6 40 9 3 2 57

Example

compare

Page 73: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

2 6 40 3 9 2 57

Example

swap

Page 74: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

2 6 40 3 9 2 57

Example

compare

Page 75: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

2 6 40 3 2 9 57

Example

swap

Page 76: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

2 6 40 3 2 9 57

Example

compare

Page 77: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

2 6 40 3 2 7 59

Example

swap

Page 78: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

2 6 40 3 2 7 59

Example

compare

Page 79: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

2 6 40 3 2 7 95

Example

swap

Page 80: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

2 6 40 3 2 7 95

Example

Page 81: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

2 6 40 3 2 7 95

Example

compare

Page 82: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

2 6 40 3 2 7 95

Example

compare

Page 83: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

2 0 46 3 2 7 95

Example

swap

Page 84: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

2 0 46 3 2 7 95

Example

compare

Page 85: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

2 0 64 3 2 7 95

Example

swap

Page 86: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

2 0 64 3 2 7 95

Example

compare

Page 87: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

2 0 34 6 2 7 95

Example

swap

Page 88: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

2 0 34 6 2 7 95

Example

compare

Page 89: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

2 0 34 2 6 7 95

Example

swap

Page 90: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

2 0 34 2 6 7 95

Example

compare

Page 91: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

2 0 34 2 6 7 95

Example

compare

Page 92: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

2 0 34 2 6 5 97

Example

swap

Page 93: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

2 0 34 2 6 5 97

Example

Page 94: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

2 0 34 2 6 5 97

Example

Are you tired yet? Bored?

Page 95: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

2 0 34 2 6 5 97

Example

compare

Page 96: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

0 2 34 2 6 5 97

Example

swap

Page 97: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

0 2 34 2 6 5 97

Example

compare

Page 98: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

0 2 34 2 6 5 97

Example

compare

Page 99: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

0 2 43 2 6 5 97

Example

swap

Page 100: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

0 2 43 2 6 5 97

Example

compare

Page 101: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

0 2 23 4 6 5 97

Example

swap

Page 102: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

0 2 23 4 6 5 97

Example

compare

Page 103: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

0 2 23 4 6 5 97

Example

compare

Page 104: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

0 2 23 4 5 6 97

Example

swap

Page 105: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

0 2 23 4 5 6 97

Example

Page 106: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

0 2 23 4 5 6 97

Example

compare

Page 107: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

0 2 23 4 5 6 97

Example

compare

Page 108: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

0 2 23 4 5 6 97

Example

compare

Page 109: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

0 2 32 4 5 6 97

Example

swap

Page 110: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

0 2 32 4 5 6 97

Example

compare

Page 111: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

0 2 32 4 5 6 97

Example

compare

Page 112: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

0 2 32 4 5 6 97

Example

Page 113: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

0 2 32 4 5 6 97

Example

compare

Page 114: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

0 2 32 4 5 6 97

Example

compare

Page 115: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

0 2 32 4 5 6 97

Example

compare

Page 116: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

0 2 32 4 5 6 97

Example

compare

Page 117: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

0 2 32 4 5 6 97

Example

Page 118: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

0 2 32 4 5 6 97

Example

Phew!

Page 119: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

On an Array

Page 120: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

9 2 06 4 3 2 57

Example

i=8

Page 121: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

9 2 06 4 3 2 57

Example

compare

i=8j=0

Page 122: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

2 9 06 4 3 2 57

Example

swap

Example

i=8j=0

Page 123: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

2 9 06 4 3 2 57

Example

compare

ExampleExample

i=8j=1

Page 124: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

2 6 09 4 3 2 57

Example

swap

ExampleExampleExample

i=8j=1

Page 125: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

2 6 09 4 3 2 57

Example

compare

ExampleExampleExampleExample

i=8j=2

Page 126: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

2 6 90 4 3 2 57

Example

swap

ExampleExampleExampleExampleExample

i=8j=2

Page 127: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

2 6 90 4 3 2 57

Example

compare

ExampleExampleExampleExampleExampleExample

i=8j=3

Page 128: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

2 6 40 9 3 2 57

Example

swap

ExampleExampleExampleExampleExampleExampleExample

i=8j=3

Page 129: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

2 6 40 9 3 2 57

Example

compare

ExampleExampleExampleExampleExampleExampleExampleExample

i=8j=4

Page 130: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

2 6 40 3 9 2 57

Example

swap

ExampleExampleExampleExampleExampleExampleExampleExampleExample

i=8j=4

Page 131: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

2 6 40 3 9 2 57

Example

compare

ExampleExampleExampleExampleExampleExampleExampleExampleExampleExample

i=8j=5

Page 132: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

2 6 40 3 2 9 57

Example

swap

ExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExample

i=8j=5

Page 133: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

2 6 40 3 2 9 57

Example

compare

ExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExample

i=8j=6

Page 134: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

2 6 40 3 2 7 59

Example

swap

ExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExample

i=8j=6

Page 135: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

2 6 40 3 2 7 59

Example

compare

ExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExample

i=8j=7

Page 136: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

2 6 40 3 2 7 95

Example

swap

ExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExample

i=8j=7

Page 137: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

2 6 40 3 2 7 95

Example sortingExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExample

Page 138: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

2 6 40 3 2 7 95

Example

compare

sortingExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExample

i=7j=0

Page 139: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

2 6 40 3 2 7 95

Example

compare

ExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExample

i=7j=1

Page 140: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

2 0 46 3 2 7 95

Example

swap

ExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExample

i=7j=1

Page 141: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

2 0 46 3 2 7 95

Example

compare

ExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExample

i=7j=2

Page 142: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

2 0 64 3 2 7 95

Example

swap

sortingExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExample

i=7j=2

Page 143: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

2 0 64 3 2 7 95

Example

compare

sortingExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExample

i=7j=3

Page 144: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

2 0 34 6 2 7 95

Example

swap

sortingExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExample

i=7j=3

Page 145: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

2 0 34 6 2 7 95

Example

compare

sortingExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExample

i=7j=4

Page 146: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

2 0 34 2 6 7 95

Example

swap

sortingExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExample

i=7j=4

Page 147: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

2 0 34 2 6 7 95

Example

compare

sortingExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExample

i=7j=5

Page 148: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

2 0 34 2 6 7 95

Example

compare

sortingExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExample

i=7j=6

Page 149: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

2 0 34 2 6 5 97

Example

swap

sortingExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExample

i=7j=6

Page 150: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

2 0 34 2 6 5 97

ExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExample

Page 151: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

2 0 34 2 6 5 97

Example

compare

sortingExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExample

i=6j=0

Page 152: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

0 2 34 2 6 5 97

Example

swap

ExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExample

i=6j=0

Page 153: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

0 2 34 2 6 5 97

Example

compare

ExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExample

i=6j=1

Page 154: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

0 2 34 2 6 5 97

Example

compare

ExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExample

i=6j=2

Page 155: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

0 2 43 2 6 5 97

Example

swap

ExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExample

i=6j=2

Page 156: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

0 2 43 2 6 5 97

Example

compare

ExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExample

i=6j=3

Page 157: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

0 2 23 4 6 5 97

Example

swap

ExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExample

i=6j=3

Page 158: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

0 2 23 4 6 5 97

Example

compare

ExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExample

i=6j=4

Page 159: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

0 2 23 4 6 5 97

Example

compare

ExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExample

i=6j=5

Page 160: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

0 2 23 4 5 6 97

Example

swap

ExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExample

i=6j=5

Page 161: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

0 2 23 4 5 6 97

ExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExample

Page 162: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

0 2 23 4 5 6 97

Example

compare

ExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExample

i=5j=0

Page 163: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

0 2 23 4 5 6 97

Example

compare

ExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExample

i=5j=1

Page 164: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

0 2 23 4 5 6 97

Example

compare

ExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExample

i=5j=2

Page 165: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

0 2 32 4 5 6 97

Example

swap

ExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExample

i=5j=2

Page 166: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

0 2 32 4 5 6 97

Example

compare

ExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExample

i=5j=3

Page 167: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

0 2 32 4 5 6 97

Example

compare

ExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExample

i=5j=4

Page 168: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

0 2 32 4 5 6 97

ExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExample

Page 169: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

0 2 32 4 5 6 97

Example

compare

ExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExample

i=4j=0

Page 170: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

0 2 32 4 5 6 97

Example

compare

ExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExample

i=4j=1

Page 171: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

0 2 32 4 5 6 97

Example

compare

ExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExample

i=4j=2

Page 172: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

0 2 32 4 5 6 97

Example

compare

ExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExample

i=4j=3

Page 173: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

0 2 32 4 5 6 97

ExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExample

Page 174: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

0 2 32 4 5 6 97

ExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExample

Page 175: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

0 2 32 4 5 6 97

Example

Page 176: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

0 2 32 4 5 6 97

Example

Phew!

Page 177: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

On an Array

Can we visualize this?

Page 178: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

On an Array

Can we visualize this?

Assume we have a random list of numbers from 0 to n-1, put in an array ASuch that A[0] is the 1st number and A[n-1] is the last

Page 179: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

On an Array

Can we visualize this?

Assume we have a random list of numbers from 0 to n-1, put in an array ASuch that A[0] is the 1st number and A[n-1] is the last

9 2 06 4 3 2 57

Page 180: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

On an Array

Can we visualize this?

Assume we have a random list of numbers from 0 to n-1, put in an array ASuch that A[0] is the 1st number and A[n-1] is the last

9 2 06 4 3 2 57

A[0] A[1] A[2] A[3] A[4] A[5] A[6] A[7] A[8]

Page 181: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

On an Array

Can we visualize this?

Assume we have a random list of numbers from 0 to n-1, put in an array ASuch that A[0] is the 1st number and A[n-1] is the last

9 2 06 4 3 2 57

A[0] A[1] A[2] A[3] A[4] A[5] A[6] A[7] A[8]

We could plot A[i] on a graph as a point with x/y coordinates i/A[i]

Page 182: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

On an Array

Can we visualize this?

Assume we have a random list of numbers from 0 to n-1, put in an array ASuch that A[0] is the 1st number and A[n-1] is the last

9 2 06 4 3 2 57

A[0] A[1] A[2] A[3] A[4] A[5] A[6] A[7] A[8]

We could plot A[i] on a graph as a point with x/y coordinates i/A[i]

Do this as the algorithm progress to see how it progresses.

Page 183: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

On an Array

Can we visualize this?

Assume we have a random list of numbers from 0 to n-1, put in an array ASuch that A[0] is the 1st number and A[n-1] is the last

9 2 06 4 3 2 57

A[0] A[1] A[2] A[3] A[4] A[5] A[6] A[7] A[8]

We could plot A[i] on a graph as a point with x/y coordinates i/A[i]

Do this as the algorithm progress to see how it progresses.

Ready?

Page 184: Reflections of ADS2 2011

Quadratic algorithms

• bubble sort• insertion sort• selection sort

sorting

Bubble Sort

On an Array

Page 185: Reflections of ADS2 2011

sorting

Bubble Sort

Show me more!

Page 186: Reflections of ADS2 2011

sorting

Bubble Sort

Show me more!

• different sorting algorithms and relative performance• a beauty contest

• what is the “sound” of sorting?• can you show me it by mime? Expressive dance?

Page 187: Reflections of ADS2 2011

sorting

Bubble Sort

NOTE to self:Bubble sort is a quadratic time algorithm.If I have to sort a data set of N objects the run time will be proportional to N2

Page 188: Reflections of ADS2 2011

sorting

Bubble Sort

NOTE to self:Bubble sort is a quadratic time algorithm.If I have to sort a data set of N objects the run time will be proportional to N2

To sort 10 numbers will take 100 units of time

Page 189: Reflections of ADS2 2011

sorting

Bubble Sort

NOTE to self:Bubble sort is a quadratic time algorithm.If I have to sort a data set of N objects the run time will be proportional to N2

To sort 10 numbers will take 100 units of timeTo sort 100 numbers will take 10,000 units of time

Page 190: Reflections of ADS2 2011

sorting

Bubble Sort

NOTE to self:Bubble sort is a quadratic time algorithm.If I have to sort a data set of N objects the run time will be proportional to N2

To sort 10 numbers will take 100 units of timeTo sort 100 numbers will take 10,000 units of timeTo sort 1000 numbers will take 1,000,000 units of time

Page 191: Reflections of ADS2 2011

Links

• sorting algorithm animation• sound of sorting (part 1)• sound of sorting (part 2)• bubble sort by folk dancing

Page 193: Reflections of ADS2 2011

I think there has never been a better time to teach Computer Science

end of part 1

Page 194: Reflections of ADS2 2011
Page 195: Reflections of ADS2 2011
Page 196: Reflections of ADS2 2011
Page 197: Reflections of ADS2 2011
Page 198: Reflections of ADS2 2011
Page 199: Reflections of ADS2 2011

Live dangerously … live like a teacher, like a Physics teacher,or Chemistry, or Biology, or …

Page 200: Reflections of ADS2 2011

Live dangerously