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

Slides:



Advertisements
Similar presentations
David Luebke 1 6/7/2014 CS 332: Algorithms Skip Lists Introduction to Hashing.
Advertisements

Hash Tables CS 310 – Professor Roch Weiss Chapter 20 All figures marked with a chapter and section number are copyrighted © 2006 by Pearson Addison-Wesley.
Introduction to Algorithms Quicksort
David Luebke 1 4/22/2015 CS 332: Algorithms Quicksort.
Algorithms Analysis Lecture 6 Quicksort. Quick Sort Divide and Conquer.
CS Section 600 CS Section 002 Dr. Angela Guercio Spring 2010.
Sorting Comparison-based algorithm review –You should know most of the algorithms –We will concentrate on their analyses –Special emphasis: Heapsort Lower.
Lecture 6 : Dynamic Hashing Bong-Soo Sohn Assistant Professor School of Computer Science and Engineering Chung-Ang University.
§7 Quicksort -- the fastest known sorting algorithm in practice 1. The Algorithm void Quicksort ( ElementType A[ ], int N ) { if ( N < 2 ) return; pivot.
ADA: 5. Quicksort1 Objective o describe the quicksort algorithm, it's partition function, and analyse its running time under different data conditions.
Randomized Algorithms Randomized Algorithms CS648 Lecture 15 Randomized Incremental Construction (building the background) Lecture 15 Randomized Incremental.
Introduction to Algorithms
ISOM MIS 215 Module 7 – Sorting. ISOM Where are we? 2 Intro to Java, Course Java lang. basics Arrays Introduction NewbieProgrammersDevelopersProfessionalsDesigners.
Sorting and selection – Part 2 Prof. Noah Snavely CS1114
Quicksort CS 3358 Data Structures. Sorting II/ Slide 2 Introduction Fastest known sorting algorithm in practice * Average case: O(N log N) * Worst case:
25 May Quick Sort (11.2) CSE 2011 Winter 2011.
Quicksort COMP171 Fall Sorting II/ Slide 2 Introduction * Fastest known sorting algorithm in practice * Average case: O(N log N) * Worst case: O(N.
Data Structures Data Structures Topic #13. Today’s Agenda Sorting Algorithms: Recursive –mergesort –quicksort As we learn about each sorting algorithm,
Updated QuickSort Problem From a given set of n integers, find the missing integer from 0 to n using O(n) queries of type: “what is bit[j]
Fundamentals of Algorithms MCS - 2 Lecture # 16. Quick Sort.
DictionaryADT and Trees. Overview What is the DictionaryADT? What are trees? Implementing DictionaryADT with binary trees Balanced trees DictionaryADT.
Sorting Heapsort Quick review of basic sorting methods Lower bounds for comparison-based methods Non-comparison based sorting.
Tirgul 10 Rehearsal about Universal Hashing Solving two problems from theoretical exercises: –T2 q. 1 –T3 q. 2.
June 13, Introduction to CS II Data Structures Hongwei Xi Comp. Sci. Dept. Boston University.
Analysis of Algorithms CS 477/677 Instructor: Monica Nicolescu.
General Computer Science for Engineers CISC 106 James Atlas Computer and Information Sciences 10/23/2009.
CSC 2300 Data Structures & Algorithms February 27, 2007 Chapter 5. Hashing.
CS 280 Data Structures Professor John Peterson. Invariants Back to Invariants! Recall the insertion sort invariant – how can we turn this into debugging.
Tirgul 8 Universal Hashing Remarks on Programming Exercise 1 Solution to question 2 in theoretical homework 2.
CS 206 Introduction to Computer Science II 04 / 29 / 2009 Instructor: Michael Eckmann.
Unit 11a 1 Unit 11: Data Structures & Complexity H We discuss in this unit Graphs and trees Binary search trees Hashing functions Recursive sorting: quicksort,
Data Structures Review Session 1
CS 206 Introduction to Computer Science II 12 / 10 / 2008 Instructor: Michael Eckmann.
COMP152 Object-Oriented Programming and Data Structures Spring 2011.
September 5, Concepts of Programming Languages Hongwei Xi Comp. Sci. Dept. Boston University.
CS 206 Introduction to Computer Science II 12 / 08 / 2008 Instructor: Michael Eckmann.
Divide-And-Conquer Sorting Small instance.  n
Introduction CSE 2320 – Algorithms and Data Structures Vassilis Athitsos University of Texas at Arlington 1.
CS10 Final Review by Glenn Sugden is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.Glenn Sugdenmons Attribution-NonCommercial-ShareAlike.
9/17/20151 Chapter 12 - Heaps. 9/17/20152 Introduction ► Heaps are largely about priority queues. ► They are an alternative data structure to implementing.
Data Structures Lecture 1: Introduction Azhar Maqsood NUST Institute of Information Technology (NIIT)
Introduction to Algorithms Jiafen Liu Sept
Computer Science 101 Fast Searching and Sorting. Improving Efficiency We got a better best case by tweaking the selection sort and the bubble sort We.
C++ Programming: From Problem Analysis to Program Design, Second Edition Chapter 19: Searching and Sorting.
Hashing Chapter 20. Hash Table A hash table is a data structure that allows fast find, insert, and delete operations (most of the time). The simplest.
MIS215 Module 0 - Intro 1 MIS 215 Module 0 Intro to Data Structures.
The Binary Heap. Binary Heap Looks similar to a binary search tree BUT all the values stored in the subtree rooted at a node are greater than or equal.
CS261 – Recitation 5 Fall Outline Assignment 3: Memory and Timing Tests Binary Search Algorithm Binary Search Tree Add/Remove examples 1.
Design and Analysis of Algorithms Dynamic Set Model Haidong Xue Summer 2012, at GSU.
Ihab Mohammed and Safaa Alwajidi. Introduction Hash tables are dictionary structure that store objects with keys and provide very fast access. Hash table.
Sorting: Implementation Fundamental Data Structures and Algorithms Klaus Sutner February 24, 2004.
Analysis of Algorithms CS 477/677 Instructor: Monica Nicolescu Lecture 7.
Divide And Conquer A large instance is solved as follows:  Divide the large instance into smaller instances.  Solve the smaller instances somehow. 
CPSC 252 Binary Heaps Page 1 Binary Heaps A complete binary tree is a binary tree that satisfies the following properties: - every level, except possibly.
Hashing 1 Hashing. Hashing 2 Hashing … * Again, a (dynamic) set of elements in which we do ‘search’, ‘insert’, and ‘delete’ n Linear ones: lists, stacks,
Week 13 - Friday.  What did we talk about last time?  Sorting  Insertion sort  Merge sort  Started quicksort.
1 Ch.19 Divide and Conquer. 2 BIRD’S-EYE VIEW Divide and conquer algorithms Decompose a problem instance into several smaller independent instances May.
DATA STRUCTURES (CS212D) Overview & Review Instructor Information 2  Instructor Information:  Dr. Radwa El Shawi  Room: 
Team assignments in CS 322 “Data Structures & Algorithms II” Jey Veerasamy CIS Adjunct Faculty Baker College Online.
TCSS 342 Autumn 2004 Version TCSS 342 Data Structures & Algorithms Autumn 2004 Ed Hong.
School of Computing Clemson University Fall, 2012
Data Structures (CS212D) Overview & Review.
CSE 143 Lecture 23: quick sort.
Intro to Computer Science CS1510 Dr. Sarah Diesburg
Ch 7: Quicksort Ming-Te Chi
Data Structures Review Session
Data Structures (CS212D) Overview & Review.
Intro to Computer Science CS1510 Dr. Sarah Diesburg
Data Structures and Algorithms
Presentation transcript:

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

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.

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.

4 Fun Algorithmic Problem Solving 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.

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

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

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(N 2 ) time instead. Example: Simplistic Hash Table 7

To sort an array A[0…N-1]: –Choose “random” index i = % N; –Partition array on value of A[i]: –Recursively sort left and right sides. We can make this run slowly (O(N 2 ) versus O(N log N)) by making sure the A[i] is always the minimum / maximum in the entire array… Example: Randomized Quicksort with Weak Random # Generator 8 A[0…N-1] A[i]elements < A[i]elements > A[i]

Ensure the max is in position i = % 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!

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 = % N. This generates a bad input of size N in O(N 2 ) 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!

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 = % N. This generates a bad input of size N in O(N 2 ) 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

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, for a large input size. Automated Grading 12

Questions / Discussion? Thanks! 13