“making mathematical reasoning fun” workshop acm sigcse, 2013

13
Algorithmically Adversarial Input Design “Making Mathematical Reasoning Fun” Workshop ACM SIGCSE, 2013 Brian C. Dean, Chad Waters School of Computing, Clemson University

Upload: orea

Post on 23-Feb-2016

39 views

Category:

Documents


0 download

DESCRIPTION

Algorithmically Adversarial Input Design. Brian C. Dean, Chad Waters School of Computing, Clemson University. “Making Mathematical Reasoning Fun” Workshop ACM SIGCSE, 2013. Intro / Motivation. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: “Making Mathematical Reasoning Fun” Workshop ACM SIGCSE, 2013

Algorithmically AdversarialInput Design

“Making Mathematical Reasoning Fun” Workshop

ACM SIGCSE, 2013

Brian C. Dean, Chad WatersSchool of Computing, Clemson University

Page 2: “Making Mathematical Reasoning Fun” Workshop ACM SIGCSE, 2013

2

Intro / Motivation

• I teach several algorithms and computational problem-solving classes at the undergraduate through graduate levels.

• I also direct the USA Computing Olympiad, which provides algorithmic problem-solving tutorials and competitions to thousands of top high-school CS students worldwide.

• In both cases, a primary challenge is making algorithmic problem-solving fun.

Page 3: “Making Mathematical Reasoning Fun” Workshop ACM SIGCSE, 2013

3

Intro / Motivation

• I teach several algorithms and computational problem-solving classes at the undergraduate through graduate levels.

• I also direct the USA Computing Olympiad, which provides algorithmic problem-solving tutorials and competitions to thousands of top high-school CS students worldwide.

• In both cases, a primary challenge is making algorithmic problem-solving fun helping students realize the intrinsic fun-ness of algorithmic problem-solving.

Page 4: “Making Mathematical Reasoning Fun” Workshop ACM SIGCSE, 2013

4

FunAlgorithmic ProblemSolving

• Articulate problem-solving concepts in a more concrete, tangible medium:Games, robots, cell phones, unplugged, multimedia

• Teach problem-solving concepts that let students re-create cutting-edge computing technology they know and appreciate:Recommendation systems, data mining, predictive text completion, web search w/Google pagerank, handheld GPS based automobile navigation

• Team exercises; collaboration / competition.

Page 5: “Making Mathematical Reasoning Fun” Workshop ACM SIGCSE, 2013

• In security / software engineering classes, students often study vulnerabilities in software or security mechanisms from a “bad guy” perspective.

• This adversarial perspective is much less common in algorithmic classes though.

• However, it made for a very successful homework exercise in my undergraduate algorithms / data structures course…

It’s More Fun to be the Bad Guy…

5

Page 6: “Making Mathematical Reasoning Fun” Workshop ACM SIGCSE, 2013

• I give students a bit of code that has some sort of algorithmic weakness.

• Students need to examine this code and then submit a program that generates a bad input for my program.

• Success is defined by:- Student program runs fast.- Student program generates an input that makes my program run slow.

The Exercise

6

Page 7: “Making Mathematical Reasoning Fun” Workshop ACM SIGCSE, 2013

Hash(x) = (3x + 17) % table_size

• By reverse-engineering the mathematics of the hash function my program uses, students can provide a set of input elements that all hash to the same entry of the hash table!

• This makes a program that should have run in O(N) time take O(N2) time instead.

Example: Simplistic Hash Table

7

x

Page 8: “Making Mathematical Reasoning Fun” Workshop ACM SIGCSE, 2013

• To sort an array A[0…N-1]:– Choose “random” index i = 123456789 % N;– Partition array on value of A[i]:

– Recursively sort left and right sides.• We can make this run slowly (O(N2) versus

O(N log N)) by making sure the A[i] is always the minimum / maximum in the entire array…

Example: Randomized Quicksortwith Weak Random # Generator

8

A[0…N-1]

A[i]elements < A[i] elements > A[i]

Page 9: “Making Mathematical Reasoning Fun” Workshop ACM SIGCSE, 2013

• Ensure the max is in position i = 123456789 % N.• When partitioning happens, the max gets pulled to

the end of the array, leaving the other 999,999 elements in the same order as before.

Constructing an Adversarial Input…

9

A[0…N-1]

A[i] = max999,999 elements < A[i]

And this should now be an adversarial input for size N = 999,999!

Page 10: “Making Mathematical Reasoning Fun” Workshop ACM SIGCSE, 2013

• We now have the insight to construct an adversarial input of size N by working backwards.

• Starting from a bad input of size N – 1, insert a new maximum element at position i = 123456789 % N.

• This generates a bad input of size N in O(N2) time.

Constructing an Adversarial Input…

10

A[0…N-1]

A[i] = max999,999 elements < A[i]

And this should now be an adversarial input for size N = 999,999!

Page 11: “Making Mathematical Reasoning Fun” Workshop ACM SIGCSE, 2013

• We now have the insight to construct an adversarial input of size N by working backwards.

• Starting from a bad input of size N – 1, insert a new maximum element at position i = 123456789 % N.

• This generates a bad input of size N in O(N2) time.

• However, using augmented balanced binary search trees, one can implement the algorithm above in only O(N log N) time, so it runs much faster than the weak quicksort algorithm provided by the instructor…

Constructing an Adversarial Input…

11

Page 12: “Making Mathematical Reasoning Fun” Workshop ACM SIGCSE, 2013

• An assignment of this sort is ideal from an instructor’s perspective since it can be automatically graded.

• Score is based on:– How fast student’s program runs (faster is better).– How slow the instructor’s program runs on the input

generated by the student program (slower is better).• For example, one could give full credit if the

student program runs in < 5 seconds and causes the instructor program to run in > 5 seconds, for a large input size.

Automated Grading

12

Page 13: “Making Mathematical Reasoning Fun” Workshop ACM SIGCSE, 2013

Questions / Discussion?

Thanks!

13