118

Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!

Embed Size (px)

Citation preview

Page 1: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!
Page 2: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!

Algorithms and Data Structures

TEACH THAT

Page 3: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!
Page 4: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!

Lassie, what’s in this ADS2 course ? Will it be interesting?

woof!

Page 5: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!

Content

• linked lists• single/doubly-linked, • insert, delete, find, min, max, …

• stacks• push/pop/size• bracket matching, RP calculator

• queues• enqueue/dequeue/size• circular queue (in array)

• recursion• see above

• big O

Page 6: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!

Content

• trees• n-ary trees: representations & properties• binary trees

• representations & properties & traversals• binary search trees

• insert/find/delete/traverse/height …• AVL trees• heap

• insert/delete/sort• splay trees• red-black trees

Continued

Page 7: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!

Content

• skip lists• Sorting

• bubble/insert/sift sort• merge sort• quick sort• bucket sort (pigeon hole sort)• bead sort

• Dictionaries• maps and hash tables

• open and closed hashing

Continued

Page 8: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!

ContentContinued

• 5 pieces of practical work• 2 of above are assessed• exam• lab every 2nd week• woof

Page 9: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!

Algorithms&

Data Structures

Algorithms

&

Data Structures

Great!

Page 10: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!
Page 11: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!

my ADS2 website under construction

(permanently)I hate moodle

Page 12: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!

Home

Page 13: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!

News

Page 14: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!

The lectures

Page 15: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!

The lectures

Page 16: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!

code & api

Page 17: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!

Lots of code in there

Page 18: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!

DEMOS

Page 19: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!

demos

Page 20: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!

Links to interesting & useful stuff

Page 21: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!

exercises

Page 22: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!

Questions & Answers

Page 23: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!

Questions & Answers

Page 24: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!

… and now for something completely different!!!

Page 25: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!

Lassie, why are algorithms and data structures important?

Page 26: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!

Lassie, will there be anything in the course that is challenging and

exciting?

Page 27: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!

I just hope I get feedback, continuously

Page 28: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!

Lassie, will you teach us to “THINK LIKE A COMPUTER SCIENTIST”?

Page 29: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!

Lassie, honestly, I’m not that experienced as a programmer. Will you help us with our programming?

Page 30: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!

Will we use BIG data sets?

Page 31: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!

woof!

Page 32: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!

1st couple of lectures “Who cares?”

Page 33: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!

If someone was to teach you to drive a car would they:

1. explain how the internal combustion engine works2. take you through the intricacies of synchromesh gears3. fully independent suspension, spring rates, and dampers4. front and real wheel drive: pros and cons5. basic aerodynamics 6. …7. …

Page 34: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!

… or would they show you the knobs and levers and take you for a spin

Page 35: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!

Go for a spin

Page 36: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!

1st lecture … “Who cares?”

Page 37: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!

Who cares?Machines are getting

bigger, faster, cheaper … do efficient data

structures and algorithms really

matter?

Page 38: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!
Page 39: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!

An emotional attachment to algorithms and data structures

An empirical study using the IMDB

Page 40: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!

An emotional attachment to algorithms and data structures

An empirical study using the IMDB

Page 41: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!

An emotional attachment to algorithms and data structures

An empirical study using the IMDB

Page 42: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!

HashSet?

Page 43: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!

ArrayList?

Page 44: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!

woof

Page 45: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!

An emotional attachment to algorithms and data structures

An empirical study using the IMDB

Page 46: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!

An emotional attachment to algorithms and data structures

An empirical study using the IMDB

We could run this in the class for 1st three entries above

Page 47: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!

So? What was that about? This is 1st & 2nd lecture

Quickly/Immediately they get to see Alg & DS can have a dramatic effectWe use real dataWe use a big data setWe show that there is an empirical side to CSComputer Science is a Science

Page 48: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!

Okay, what’s next

Page 49: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!

The TSP challenge

Page 50: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!

It’s impossible to cover all the material we want to cover

Page 51: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!

So give them something that will draw them in …

Page 52: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!

Give them something that is fun …

Page 53: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!

The TSP challenge

100 Glasgow postal codes in a 5K radius

Find the shortest tour

not assessed, no marks, … a crappy trophy

Email me tour wheneverI will maintain website

Basic code with GUI on course website

Page 54: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!

Code is here

Page 55: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!

Data sets are here

Page 56: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!

Code is here

Page 57: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!

Our very own demo program

Page 58: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!

Our very own demo program

Page 59: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!

Our very own demo program

Page 60: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!

Your challenge is do write a method for the TSP class to find as short a route as possible round Glasgow. You have all

semester to do this.

Page 61: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!

That took about a week to develop

Furthest insertion algorithm used

Easy to add a solver

Students can do this if they want (no pressure)

Thanks SoCS for letting me do this

Page 62: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!

Footnote for all …

Some crappy prizes:

1. Green jacket2. Blue Riband3. Pint of milk at the Indy 5004. Victoria Cross5. A gold star6. …7. 4th year project prize

I am NOT kidding

Page 63: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!

next?

Page 64: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!

Instant feedback!!!

Page 65: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!

btree as an example

Page 66: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!

btree

btree

Page 67: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!

btree

btree

Page 68: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!

btree

btree

Page 69: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!

btree

btree

Page 70: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!

Ewe have to implement some of

the methods and test them

Page 71: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!

Any other examples Lassie?

Page 72: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!

Doubly Linked List

Page 73: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!

Any others

Page 74: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!

avlTree and emailOfDoom

Page 75: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!

avlTree and emailOfDoom

Page 76: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!

avlTree and emailOfDoom

Page 77: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!

Feedback?

Page 78: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!

Well, there are also programs that use your classes and methods and test them against

data sets, checks results are correct, complexity is within limits and gives you

“brownie” points. Richard’s seen this before. He could tell you more if you want.

Page 79: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!

What was this “THINK LIKE A COMPUTER SCIENTIST” stuff?

Page 80: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!

Count from zero?

Page 81: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!
Page 82: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!
Page 83: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!
Page 84: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!
Page 85: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!

I, being of sound mody and bind, herby swear that I will, on occasion, write java code in the class, that I will

explain what I am thinking and doing. I also swear that I will debug code in the class and I will explain what I am

thinking and what I am doing. I will try my best to explain what I think is good and what is bad as a Computer Programmer … as Almighty Dog is my

witness.

Page 86: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!

baaa!

Page 87: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!

An Example

Page 88: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!

Example of “Thinking Like a Computer Scientist”

I spent one day tracking down a bug in ADS2 code

I fixed it

No big deal

But wait. Why throw that day away?

Do something with it!

Page 89: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!

anatomy of a bug

Page 90: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!

anatomy of a bug

Page 91: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!

anatomy of a bug

Page 92: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!

AVL Trees

Anatomy of a bug

Page 93: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!

I wrote java code for the avl tree: the data structure, a test/demo programand managed to display it …

I felt … smug

Page 94: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!
Page 95: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!

smug

smugsmug

smug

smug

It was written all over me

Page 96: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!

… so smug that I just HAD to demo it to a friend/colleague …

Dr. Chris “unworthy” Unsworth

Page 98: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!

… and this is what happened

Page 99: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!
Page 100: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!
Page 101: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!
Page 102: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!
Page 103: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!
Page 104: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!
Page 105: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!
Page 106: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!
Page 108: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!
Page 109: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!

Calm down … think

Page 110: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!

Example

Page 111: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!

Example

Page 112: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!

Example

Page 113: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!

Example

Page 114: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!

So?

Page 115: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!

The sheep have a point dude.

Page 116: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!

This is what I hope to do

1. Capture the students’ interest2. Convince the class that studying/knowing/using ADS is worthwhile3. Teach students the basics of ADS & a wee bit more4. Develop students’ programming skills (and their programming appreciation)5. Give fast feedback6. Develop students’ programming skills (I already said that, didn’t I?)7. When appropriate, expose the thinking of a Computer Scientist8. Use realistic data sets where possible

Page 117: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!

Available from the gift shop now

Page 118: Algorithms and Data Structures TEACH THAT Lassie, what’s in this ADS2 course ? Will it be interesting? woof!