Great Theoretical Ideas in Computer Science

71
Great Theoretical Ideas in Computer Science 15-251

description

15-251. Great Theoretical Ideas in Computer Science. Administrative details. Course Staff. TAs A: JD Nir B: Tim Wilson C: Mark Kai D: Adam Blank E: Sang Tian F: Jasmine Peterson G:Andrew Audibert Shashank Singh. Prof. Ryan O’Donnell. Office hours start Wednesday. - PowerPoint PPT Presentation

Transcript of Great Theoretical Ideas in Computer Science

Page 1: Great Theoretical Ideas in Computer Science

Great Theoretical Ideas in Computer Science

15-251

Page 2: Great Theoretical Ideas in Computer Science

Administrative details

Page 3: Great Theoretical Ideas in Computer Science

Course Staff

Prof. Danny Sleator

Prof. Ryan O’Donnell

TAs

A: JD NirB: Tim WilsonC: Mark KaiD: Adam BlankE: Sang TianF: Jasmine PetersonG: Andrew Audibert

Shashank Singh

Office hours start Wednesday.

Page 4: Great Theoretical Ideas in Computer Science

Web Sites

https://colormygraph.ugrad.cs.cmu.edu

= http://www.cs.cmu.edu/~15251

Announcements, Calendar, Notes, Homeworks, …

http://piazza.com/cmu/spring2012/15251

Bulletin Board: Questions, Comments, Announcements, …

Page 5: Great Theoretical Ideas in Computer Science

Textbook

There is no textbook.

Slides will be posted on the website.

Some supplementary notes will also be posted.

Page 6: Great Theoretical Ideas in Computer Science

Grading

28% Homework (12, lowest one dropped) 5% Quizzes (12, lowest two dropped) 2% Participation35% Midterms (3, lowest one counts half)30% Final

Page 7: Great Theoretical Ideas in Computer Science

Homework

Homeworks out/due each Thursday at 11:59pm.

They are hard.

Must be typeset in LaTeX, submitted online.

5 “late days” for the semester, ≤ 3 per HW.

Turned in any time Friday: costs 1 late day Turned in any time Saturday: costs 2 late days Turned in any time Sunday: costs 3 late days After Sunday: grade of 0.

Page 8: Great Theoretical Ideas in Computer Science

Collaboration

On each HW, you may work in a group of ≤ 4 people.

You must report who you worked with.

You must think about the problems yourself for ≥ 1 hour before discussing them with others.

You must write up all solutions by yourself.

Page 9: Great Theoretical Ideas in Computer Science

CheatingHandled in accordance with university policy: http://www.cmu.edu/policies/documents/Cheating.html

You MAY NOT:

You MAY:

You MUST: sign and return the Honor Code today.

Share written work. (Erase all whiteboards.)Get help from anyone besides your HW collaborators, staff.Refer to solutions/materials from earlier versions of 251.Search the web/books for specific homework problems.

Get help from others/books/web on ‘general topics’ (“induction”, “random variable”, “diagonalization”)Use tools like Mathematica/Maple/Wolfram Alpha.

Page 10: Great Theoretical Ideas in Computer Science

Quizzes

Every Tuesday (a few exceptions), beginning of class

The quiz is DUE AT 3:07pm. Therefore, do NOT be late to class.

Tested on material from the prior week.

These are designed to be easy, assuming you are keeping up with the lectures.

Page 11: Great Theoretical Ideas in Computer Science

Midterms

Designed to be doable in 1 hour.

You will have 3 hours.

“Semi-cumulative.”

Held Wednesdays, 6pm – 9pm at locations TBD.

February 15, March 21, April 18

Mark these dates on your calendar now!

Page 12: Great Theoretical Ideas in Computer Science

Automatic A

There are 4 “Automatic A” problems on website.

Solve one, get an A in the course. (Actually +2 letter grades.)

All standard homework rules apply (except groups can submit jointly written solution).

At most one submission per person/group per semester.

They are super-hard… but some easier versions mayappear on homeworks or tests…

Page 13: Great Theoretical Ideas in Computer Science

15-251: Great Theoretical Ideas in Computer Science

Pancakes With A Problem

Lecture 1

Page 14: Great Theoretical Ideas in Computer Science

Feel free to ask questions

Page 15: Great Theoretical Ideas in Computer Science

He does this by grabbing several from the top and flipping them over, repeating this (varying the number he flips) as many times as necessary.

The chef in our place is sloppy; when she prepares pancakes they come out all different sizes.

When the waiter delivers them to a customer, he rearranges them (so that the smallest is on top, and so on, down to the largest at the bottom).

Page 16: Great Theoretical Ideas in Computer Science

How do we sort this stack?How many flips do we need?

Page 17: Great Theoretical Ideas in Computer Science

How do we sort this stack?How many flips do we need?

Page 18: Great Theoretical Ideas in Computer Science

How do we sort this stack?How many flips do we need?

2 flips sufficient2 flips necessary

Page 19: Great Theoretical Ideas in Computer Science

How do we sort this stack?How many flips do we need?

Page 20: Great Theoretical Ideas in Computer Science

Developing Notation:Turning pancakes into numbers

5

2

3

4

1

52341

Page 21: Great Theoretical Ideas in Computer Science

How do we sort this stack?How many flips do we need?

52341

Page 22: Great Theoretical Ideas in Computer Science

4 flips are sufficient

12345

52341

43215

23415

14325

Page 23: Great Theoretical Ideas in Computer Science

Best way to sort this stack?

Let X be the smallest number of flips that cansort this specific stack.

? ≤ X ≤ ?Upper Bound

Lower Bound 4

52341

Page 24: Great Theoretical Ideas in Computer Science

Is 4 a lower bound?What would it take it show that?

? ≤ X ≤ ?Upper Bound

Lower Bound 4

A convincing argument that every way

of sorting the stackuses at least 4 flips.

52341

Page 25: Great Theoretical Ideas in Computer Science

Four Flips Are Necessary

52341

41325

14325

Second flip has to bring 4 to the top, because…

First flip has to put 5 on bottom, because…

If we could do it in three flips:

Page 26: Great Theoretical Ideas in Computer Science

Best way to sort?

Let X be the smallest number of flips that cansort this specific stack.

? ≤ X ≤ ?Upper Bound

Lower Bound 4

52341

4

X = 4

Page 27: Great Theoretical Ideas in Computer Science

Matching upper and lower bounds!

? ≤ X ≤ ?Upper Bound

Lower Bound 44

X = 4

Page 28: Great Theoretical Ideas in Computer Science

52341

4

54321

1

12345

0

54123

2

?????

P5

Page 29: Great Theoretical Ideas in Computer Science

5th Pancake Number

Number of flips required to sort when your worst enemy gives you a stack of 5 pancakes

P5 =

MAX over all 5-stacks Sof MIN # of flips to sort S

P5 =

Page 30: Great Theoretical Ideas in Computer Science

? ≤ P5 ≤ ? Upper Bound

Lower Bound 4

5th Pancake Number

Fact: P5 = 5

1. Show a specific 5-stack.

2. Argue that every way of sorting this stack uses at least 5 flips.

Give a way of sorting every 5-stack using

at most 5 flips.

To show P5 ≥ 5 ? To show P5 ≤ 5 ?

Page 31: Great Theoretical Ideas in Computer Science

What is Pn for small n?

Can you do

n = 0, 1, 2, 3 ?

Page 32: Great Theoretical Ideas in Computer Science

Initial Values of Pn

n 30 1 2

Pn 0 0 1 3

Page 33: Great Theoretical Ideas in Computer Science

P3 = 3

• Biggest one to bottom using ≤ 2 flips.

• Smallest one to top using ≤ 1 flip.

1. Show a specific 3-stack.

2. Argue that every way of sorting this stack uses at least 3 flips.

To show P3 ≥ 3 ?

132

Give a way of sorting every 3-stack using

at most 3 flips.

To show P3 ≤ 3 ?

Page 34: Great Theoretical Ideas in Computer Science

? ≤ Pn ≤ ?Lower Bound

nth Pancake Number

Upper Bound

“What is the best upper boundand lower bound I can prove?”

Page 35: Great Theoretical Ideas in Computer Science

? ≤ Pn ≤ ?

nth Pancake Number

Upper Bound

Let’s start by thinking about an upper bound.

Page 36: Great Theoretical Ideas in Computer Science

??????????

n

Upper Bound on Pn

Fix the biggest pancake.

Page 37: Great Theoretical Ideas in Computer Science

??????????

Upper Bound on Pn

n

??????????

n ??????????n

n−1

Fix the biggest pancake.

Page 38: Great Theoretical Ideas in Computer Science

??????????

Upper Bound on Pn

Fix pancake #n≤ 2 flips

n

??????????

n ??????????n

Fix pancake #n−1≤ 2 flips

n-1

Fix pancake #n−2≤ 2 flips

n-2Fix pancake #2

≤ 2 flips

• • •

n-3•••3

Fix pancake #3≤ 2 flips

21

≤ 2n−2

Page 39: Great Theoretical Ideas in Computer Science

??????????

Upper Bound on Pn

Fix pancake #n≤ 2 flips

n

??????????

n ??????????n

Fix pancake #n−1≤ 2 flips

n-1

Fix pancake #n−2≤ 2 flips

n-2Fix pancake #2

≤ 1 flip

• • •

n-3•••3

Fix pancake #3≤ 2 flips

??

≤ 2n−3

Page 40: Great Theoretical Ideas in Computer Science

Upper Bound on Pn

Fix pancake #n≤ 2 flips

Fix pancake #n−1≤ 2 flips

Fix pancake #n−2≤ 2 flips

Fix pancake #2≤ 1 flip

• • •

Fix pancake #3≤ 2 flips

≤ 2n−3

Bring-To-Top Method

shows Pn ≤ 2n−3

assuming n ≥ 2.

Page 41: Great Theoretical Ideas in Computer Science

? Pn 2n−3

Let’s think about a lower bound for Pn

1. Show a specific n-stack.

2. Argue that every way of sorting this stack uses a lot of flips.

Page 42: Great Theoretical Ideas in Computer Science

•••

17151311975•••

This stack seemspretty painful!

Lower Bound on Pn

Page 43: Great Theoretical Ideas in Computer Science

•••

17151311975•••

Breaking-Apart Argument

Suppose the stack has an adjacent pair which should not be adjacent in the end.

Spatula must go between them at least once.

(“Adjacent pair” includes bottom pancake and the plate.)

Each flip can achieve at most 1 “break-apart”.

Page 44: Great Theoretical Ideas in Computer Science

Proof of Pn ≥ nn•••642

n-1•••531

S

S contains n adjacent pairs which need to be broken apart, each necessitating at least one flip.

Case 1: n is even.

Detail: Assuming n > 4.

4231

Page 45: Great Theoretical Ideas in Computer Science

Proof of Pn ≥ nn-1•••642n•••531

S

S contains n adjacent pairs which need to be broken apart, each necessitating at least one flip.

Case 2: n is odd.

Detail: Assuming n > 3.231

Page 46: Great Theoretical Ideas in Computer Science

Upper and lower bounds are within a factor of 2.

Upper Bound

Lower Bound

n Pn 2n−3(for n > 4)

Page 47: Great Theoretical Ideas in Computer Science

From any n-stack to sorted n-stack in ≤ Pn

Slight Digression

From sorted n-stack to any n-stack in ≤ Pn ?

Reverse the sequence of flips used to sort!

Hence: any n-stack to any n-stack in ≤ 2Pn

Is there a better way?

Page 48: Great Theoretical Ideas in Computer Science

Any Stack S to Any Stack T in ≤ Pn

S: 4,3,5,1,2 T: 5,1,4,3,2

3,4,1,2,5 1,2,3,4,5

Rename the pancakes in T to be 1,2,3,…,n

Rewrite S using the new naming scheme

In ≤ Pn flips can sort “new S”.

The same sequence of flips also brings S to T.

“new S”

Page 49: Great Theoretical Ideas in Computer Science

The Known Pancake Numbersn Pn

12345678910111213141516171819

013457891011131415161718192022

Page 50: Great Theoretical Ideas in Computer Science

P20 is unknown

20•19•18•⋅⋅⋅•2•1 = 20! possible 20-stacks

20! = 2.43 × 1018

(2.43 exa-pancakes)

Brute-force analysis is impossible!

It is either 23 or 24, we don’t know which.

Page 51: Great Theoretical Ideas in Computer Science

Is This Really Computer Science?

Page 52: Great Theoretical Ideas in Computer Science

Posed in Amer. Math. Monthly 82(1), 1975, by “Harry Dweighter” (haha).

AKA Jacob Goodman, a computational geometer.

Page 53: Great Theoretical Ideas in Computer Science

In 1977, the observations we have made so far

were published byMike Garey, David Johnson, & Shen Lin

Page 54: Great Theoretical Ideas in Computer Science

(17/16)n ≤ Pn ≤ (5/3)n+5/3

Discrete Mathematics 27(1), 1979

Bounds ForSorting By Prefix Reversal

by: William H. Gates (Microsoft, Albuquerque NM) Christos Papadimitriou (UC Berkeley)

upper bound alsoby Győri & Turán

Page 55: Great Theoretical Ideas in Computer Science

(15/14)n ≤ Pn ≤ (5/3)n+5/3

“On the Diameter of the Pancake Network”Journal of Algorithms 25(1), 1997

by Hossain Heydari and Hal Sudborough

Page 56: Great Theoretical Ideas in Computer Science

(15/14)n ≤ Pn ≤ (18/11)n

“An (18/11)n Upper Bound ForSorting By Prefix Reversals”Theoretical Computer Science 410(36), 2009

by B. Chitturi, W. Fahle, Z. Meng, L. Morales, C.O. Shields, I.H. Sudborough, W. Voit

@ UT Dallas

Page 57: Great Theoretical Ideas in Computer Science

(3/2)n−1 ≤ BPn ≤ 2n+3

Burnt Pancakes

Page 58: Great Theoretical Ideas in Computer Science

(3/2)n ≤ BPn ≤ 2n−2

Burnt Pancakes

“On The Problem Of Sorting Burnt Pancakes”Discrete Applied Math. 61(2), 1995

by David S. Cohen and Manuel BlumX.

Page 59: Great Theoretical Ideas in Computer Science

Worst Case: There is an algorithm using ≤ (18/11)n flips, even when your worst enemy gives you stack of n pancakes

Average Case: There is an algorithm using ≤ (17/12)n flips on average when given a random stack of n pancakes

(Josef Cibulka, 2009)

Page 60: Great Theoretical Ideas in Computer Science

Applications

Page 61: Great Theoretical Ideas in Computer Science

“The Pancake Network”on n! nodes

Nodes are named after the n! different stacks of n pancakes

Put a link between two nodes if you can go between them with one flip

Page 62: Great Theoretical Ideas in Computer Science

Pancake Network, n = 3

123

321

213

312

231

132

Page 63: Great Theoretical Ideas in Computer Science

Pancake Network, n = 4

Page 64: Great Theoretical Ideas in Computer Science

Pn

Pancake Network:Message Routing Delay

What is the maximum distance between two nodes in the pancake network?

Page 65: Great Theoretical Ideas in Computer Science

If up to n−2 nodes get hit by lightning, the network remains connected, even though each node is connected to only n−1 others

The Pancake Network is optimally reliable for its number of nodes and links

Pancake Network:Reliability

Page 66: Great Theoretical Ideas in Computer Science

Computational BiologyTransforming Cabbage Into Turnip:

polynomial algorithm for sorting signed permutations by reversalby S. Hannenhalli & P. Pevzner

Of Mice And Men: algorithms for evolutionary distances between genomes with translocation

by J. Kececioglu and R. Ravi

Page 67: Great Theoretical Ideas in Computer Science
Page 68: Great Theoretical Ideas in Computer Science

One “Simple” Puzzle

A host of problems and applications

at the frontiers of

science

Page 69: Great Theoretical Ideas in Computer Science

High Level Point

Computer Science is not merely about computers and programming — it is about mathematically modeling our world, and about finding better and better ways to solve problems.

Today’s lecture is a microcosm of this.

Page 70: Great Theoretical Ideas in Computer Science

Definitions of: nth pancake number upper bound lower bound

Proof of: Bring-To-Top Breaking-Apart ANY to ANY in ≤ Pn

Study Guide

Page 71: Great Theoretical Ideas in Computer Science

Homework 1: Puzzle Hunt.

Begins now.

Turn in your signed Honor Code.

Go to HW1 on the course web site.

Special homework rules exceptions:1. Work in randomly pre-selected teams of 42. May use the Internet as much as you want