Reflections of ADS2 2011
description
Transcript of Reflections of ADS2 2011
![Page 1: Reflections of ADS2 2011](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/1.jpg)
Reflections of ADS2 2011
![Page 2: Reflections of ADS2 2011](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/2.jpg)
“There has never been a better time to teach Computer Science”
Patrick Prosser 2011
![Page 3: Reflections of ADS2 2011](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/3.jpg)
![Page 4: Reflections of ADS2 2011](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/4.jpg)
Course home page
![Page 5: Reflections of ADS2 2011](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/5.jpg)
course content
![Page 6: Reflections of ADS2 2011](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/6.jpg)
Course content
![Page 7: Reflections of ADS2 2011](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/7.jpg)
Course content
![Page 8: Reflections of ADS2 2011](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/8.jpg)
Course content
![Page 9: Reflections of ADS2 2011](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/9.jpg)
Aims & Objectives
![Page 10: Reflections of ADS2 2011](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/10.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/11.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/12.jpg)
We are always learning
![Page 13: Reflections of ADS2 2011](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/13.jpg)
![Page 14: Reflections of ADS2 2011](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/14.jpg)
exercises
![Page 15: Reflections of ADS2 2011](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/15.jpg)
exercises
5 exercises, 2 are assessed, plus a zero exercise and a challenge
![Page 16: Reflections of ADS2 2011](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/16.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/17.jpg)
exercises… for instance
1st part of the exercise, code stub
![Page 18: Reflections of ADS2 2011](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/18.jpg)
exercises… for instance
1st part of the exercise, code stub
![Page 19: Reflections of ADS2 2011](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/19.jpg)
Experiments in the Lecture
![Page 20: Reflections of ADS2 2011](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/20.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/21.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/22.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/23.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/24.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/25.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/26.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/27.jpg)
Experiments on the bench (in lecture)Binary Search Trees v AVL Trees
Hashing (different functions)
Etc …
![Page 28: Reflections of ADS2 2011](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/28.jpg)
![Page 29: Reflections of ADS2 2011](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/29.jpg)
The students have lapTops
![Page 30: Reflections of ADS2 2011](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/30.jpg)
lapTops in the lectures
![Page 31: Reflections of ADS2 2011](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/31.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/32.jpg)
We shall keep sending them
lapTops in the lectures
![Page 33: Reflections of ADS2 2011](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/33.jpg)
What should we do with student lapTops in the lecture theatre?
![Page 34: Reflections of ADS2 2011](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/34.jpg)
![Page 35: Reflections of ADS2 2011](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/35.jpg)
The lecture theatre
![Page 36: Reflections of ADS2 2011](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/36.jpg)
Boyd Orr Lecture Theatre 2
![Page 37: Reflections of ADS2 2011](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/37.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/38.jpg)
Boyd Orr Lecture Theatre 2
I love BO2
![Page 39: Reflections of ADS2 2011](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/39.jpg)
Boyd Orr Lecture Theatre 2
I love the smell of Napalm in the morning ….
![Page 40: Reflections of ADS2 2011](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/40.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/41.jpg)
We videoed all the lectures
… and what happened?
![Page 42: Reflections of ADS2 2011](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/42.jpg)
We videoed all the lectures
Attendance fell (but hey, Stanford ended up with 20 physical students)
40% < 40%
![Page 43: Reflections of ADS2 2011](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/43.jpg)
attendance
Swipe that!
![Page 44: Reflections of ADS2 2011](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/44.jpg)
What about the students?
![Page 45: Reflections of ADS2 2011](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/45.jpg)
What about the students?
- Mostly good- Surprising number are excellent- Thanks to 1st year and 1st semester
![Page 46: Reflections of ADS2 2011](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/46.jpg)
![Page 47: Reflections of ADS2 2011](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/47.jpg)
The End
and yes
it was all my own work
![Page 48: Reflections of ADS2 2011](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/48.jpg)
… 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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/49.jpg)
“This is the best time to teach CS”
![Page 50: Reflections of ADS2 2011](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/50.jpg)
An example, using sorting
![Page 51: Reflections of ADS2 2011](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/51.jpg)
Sorting, what’s that then?
Given a collection of data, get it into order …
![Page 52: Reflections of ADS2 2011](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/52.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/53.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/54.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/55.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/56.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/57.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/58.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/59.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/60.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/61.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/62.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/63.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/64.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/65.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/66.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/67.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/68.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/69.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/70.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/71.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/72.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/73.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/74.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/75.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/76.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/77.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/78.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/79.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/80.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/81.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/82.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/83.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/84.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/85.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/86.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/87.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/88.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/89.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/90.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/91.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/92.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/93.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/94.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/95.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/96.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/97.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/98.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/99.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/100.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/101.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/102.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/103.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/104.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/105.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/106.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/107.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/108.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/109.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/110.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/111.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/112.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/113.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/114.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/115.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/116.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/117.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/118.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/119.jpg)
Quadratic algorithms
• bubble sort• insertion sort• selection sort
sorting
Bubble Sort
On an Array
![Page 120: Reflections of ADS2 2011](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/120.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/121.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/122.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/123.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/124.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/125.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/126.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/127.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/128.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/129.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/130.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/131.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/132.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/133.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/134.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/135.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/136.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/137.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/138.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/139.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/140.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/141.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/142.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/143.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/144.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/145.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/146.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/147.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/148.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/149.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/150.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/151.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/152.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/153.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/154.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/155.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/156.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/157.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/158.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/159.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/160.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/161.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/162.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/163.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/164.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/165.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/166.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/167.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/168.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/169.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/170.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/171.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/172.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/173.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/174.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/175.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/176.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/177.jpg)
Quadratic algorithms
• bubble sort• insertion sort• selection sort
sorting
Bubble Sort
On an Array
Can we visualize this?
![Page 178: Reflections of ADS2 2011](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/178.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/179.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/180.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/181.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/182.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/183.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/184.jpg)
Quadratic algorithms
• bubble sort• insertion sort• selection sort
sorting
Bubble Sort
On an Array
![Page 185: Reflections of ADS2 2011](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/185.jpg)
sorting
Bubble Sort
Show me more!
![Page 186: Reflections of ADS2 2011](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/186.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/187.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/188.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/189.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/190.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/191.jpg)
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](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/193.jpg)
I think there has never been a better time to teach Computer Science
end of part 1
![Page 194: Reflections of ADS2 2011](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/194.jpg)
![Page 195: Reflections of ADS2 2011](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/195.jpg)
![Page 196: Reflections of ADS2 2011](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/196.jpg)
![Page 197: Reflections of ADS2 2011](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/197.jpg)
![Page 198: Reflections of ADS2 2011](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/198.jpg)
![Page 199: Reflections of ADS2 2011](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/199.jpg)
Live dangerously … live like a teacher, like a Physics teacher,or Chemistry, or Biology, or …
![Page 200: Reflections of ADS2 2011](https://reader038.fdocuments.in/reader038/viewer/2022103006/56813a00550346895da1c7d7/html5/thumbnails/200.jpg)
Live dangerously