andrew’s leap 2011

53
Andrew’s Leap 2011

Upload: myrna

Post on 24-Feb-2016

28 views

Category:

Documents


0 download

DESCRIPTION

Andrew’s Leap 2011. Steven Rudich. Pancakes With A Problem . - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Andrew’s Leap  2011

Andrew’s Leap 2011

Page 2: Andrew’s Leap  2011

Pancakes With A Problem Steven

Rudich

Page 3: Andrew’s Leap  2011

The chef at our place is sloppy, and when he prepares a stack of

pancakes they come out all different sizes. Therefore, when I

deliver them to a customer, on the way to the table I rearrange them (so that the smallest winds up on

top, and so on, down to the largest at the bottom) by grabbing several

from the top and flipping them over, repeating this (varying the number I flip) as many times as

necessary.

Page 4: Andrew’s Leap  2011

Developing A Notation:Turning pancakes into numbers

Page 5: Andrew’s Leap  2011

Developing A Notation:Turning pancakes into numbers

1

2

3

4

5

Page 6: Andrew’s Leap  2011

Developing A Notation:Turning pancakes into numbers

2

3

4

5

1

Page 7: Andrew’s Leap  2011

Developing A Notation:Turning pancakes into numbers

52341

Page 8: Andrew’s Leap  2011

So how many flips to sort this particular stack?

52341

Page 9: Andrew’s Leap  2011

4 Flips Are Sufficient

12345

52341

43215

23415

14325

Page 10: Andrew’s Leap  2011

Algebraic Representation

52341

X = The smallest number of flips required to sort:

? X ?Upper Bound

Lower Bound

Page 11: Andrew’s Leap  2011

Algebraic Representation

52341

X = The smallest number of flips required to sort:

? X 4Upper Bound

Lower Bound

Page 12: Andrew’s Leap  2011

Algebraic Representation

52341

X = The smallest number of flips required to sort:

1 X 4Upper Bound

Lower Bound

Page 13: Andrew’s Leap  2011

Algebraic Representation

52341

X = The smallest number of flips required to sort:

2 X 4Upper Bound

Lower Bound

Page 14: Andrew’s Leap  2011

Algebraic Representation

52341

X = The smallest number of flips required to sort:

3 X 4Upper Bound

Lower Bound

Page 15: Andrew’s Leap  2011

4 Flips Are Necessary

52341

41325

14325

Flip 1 has to put 5 on bottom.Flip 2 must bring 4 to top.

Page 16: Andrew’s Leap  2011

Algebraic Representation

52341

X = The smallest number of flips required to sort:

4 X 4Upper Bound

Lower Bound

Page 17: Andrew’s Leap  2011

Upper Bound

Lower Bound

4 X 4

X = 4

Page 18: Andrew’s Leap  2011

5th Pancake Number

P5 = The number of flips required to sort the

worst case stack of 5 pancakes.

? P5 ?Upper Bound

Lower Bound

Page 19: Andrew’s Leap  2011

5th Pancake Number

P5 = The number of flips required to sort the

worst case stack of 5 pancakes.

4 P5 ?Upper Bound

Lower Bound

Page 20: Andrew’s Leap  2011

The 5th Pancake Number: The MAX of the X’s

120

1199

32 . . . . . . .

X1 X2 X3 X119 X120

52341

4

Page 21: Andrew’s Leap  2011

nth Pancake Number

Pn = The number of flips required to sort the

worst case stack of n pancakes.

? Pn ?Upper Bound

Lower Bound

Page 22: Andrew’s Leap  2011

? Pn ?

What bounds can you prove on

Pn?

Page 23: Andrew’s Leap  2011

Bring To Top Method Bring biggest to top. Place it on bottom. Bring next largest to

top. Place second from

bottom. And so on…

Page 24: Andrew’s Leap  2011

Upper Bound On Pn:Bring To Top Method For n

PancakesIf n=1, no work - we are done.Otherwise, flip pancake n to top and then flip it to position n.

Now use: Bring To Top Method For n-1 Pancakes

Total Cost: at most 2(n-1) = 2n –2 flips.

Page 25: Andrew’s Leap  2011

Better Upper Bound On Pn:Bring To Top Method For n

PancakesIf n=2, at most one flip, we are done.Otherwise, flip pancake n to top and then flip it to position n.

Now use: Bring To Top Method

For n-1 Pancakes

Total Cost: at most 2(n-2) + 1 = 2n –3 flips.

Page 26: Andrew’s Leap  2011

Bring to top not always optimal for a particular stack

5 flips, but can be done in 4 flips

32145

52341

23145

41325

14325

Page 27: Andrew’s Leap  2011

? Pn 2n - 3

What bounds can you prove on

Pn?

Page 28: Andrew’s Leap  2011

916

Breaking Apart ArgumentSuppose a stack S contains a pair of adjacent pancakes that will not be adjacent in the sorted stack. Any sequence of flips that sorts stack S must involve one flip that inserts the spatula between that pair and breaks them apart.

Page 29: Andrew’s Leap  2011

916

Breaking Apart ArgumentSuppose a stack S contains a pair of adjacent pancakes that will not be adjacent in the sorted stack. Any sequence of flips that sorts stack S must involve one flip that inserts the spatula between that pair and breaks them apart. Furthermore, this same principle is true of the “pair” formed by the bottom pancake of S and the plate.

Page 30: Andrew’s Leap  2011

n PnSuppose n is even. S contains n pairs that will need to be broken apart during any sequence that sorts stack S.

2468..n1357..

n-1

S

Page 31: Andrew’s Leap  2011

n PnSuppose n is odd. S contains n pairs that will need to be broken apart during any sequence that sorts stack S.

1357..n2468..

n-1

S

Detail: This construction only works when n>3

Page 32: Andrew’s Leap  2011

n Pn 2n - 3

Bring To Top is

within a factor of two of

optimal

Page 33: Andrew’s Leap  2011

n Pn 2n - 3So starting

from ANY stack we can get to

the sorted stack using no more than Pn

flips.

Page 34: Andrew’s Leap  2011

From ANY stack to Sorted Stack in · Pn

Can you see why we can get from the Sorted

stack to ANY stack in · Pn

flips?Reverse the

sequences we use to sort.

Page 35: Andrew’s Leap  2011

From Sorted Stack to ANY stack in · Pn

Can you see why we can

get from ANY stack S to

ANY stack T in · Pn flips?

Page 36: Andrew’s Leap  2011

From ANY Stack S to ANY stack T in Pn

43512

14352

S T

Page 37: Andrew’s Leap  2011

From ANY Stack S to ANY stack T in Pn

RENAME PANCAKES IN YELLOWSO THAT S IS SORTED. THIS FIXES THE YELLOW ORDERING OF THE STACK T.

43512

14352

41235

12345

S T

Page 38: Andrew’s Leap  2011

The Known Pancake Numbers

123456789

10111213

01345

n Pn

789

1011131415

14 1615 1716 1817 19

Page 39: Andrew’s Leap  2011

P18 Is Unknown

18! Orderings of 18 pancakes.

18! = 6,402,373,705,728,000

Page 40: Andrew’s Leap  2011

Burnt Pancake Numbers

123456789

10

1468

101214151718

n Pn

Page 41: Andrew’s Leap  2011

Is This Really Computer Science?

Page 42: Andrew’s Leap  2011

Posed in Amer. Math. Monthly 82 (1) (1975),

“Harry Dweighter” a.k.a. Jacob Goodman

Page 43: Andrew’s Leap  2011

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

Bill Gates & Christos

Papadimitriou: Bounds For Sorting By

Prefix Reversal. Discrete

Mathematics, vol 27, pp 47-

57, 1979.

Page 44: Andrew’s Leap  2011

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

H. Heydari & H. I. Sudborough:

On the Diameter of he

Pancake Network. Journal of

Algorithms, vol 25, pp 67-94,

1997.

Page 45: Andrew’s Leap  2011

Pn 18n/11An (18/11)n Upper

Bound for Sorting by Prefix Reversals

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

Sudborough, and W. Voit. Theoretical

Computer Science, to appear

Page 46: Andrew’s Leap  2011

Pancake Network:Definition For n! Nodes

For each node, assign it the name of one of the n! stacks of n pancakes.

Put a wire between two nodes if they are one flip apart.

Page 47: Andrew’s Leap  2011

Network For n=3

123

321

213

312

231

132

Page 48: Andrew’s Leap  2011

Network For n=4

Page 49: Andrew’s Leap  2011

Pancake Network:Message Routing Delay

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

Pn

Page 50: Andrew’s Leap  2011

Pancake Network:Reliability

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

The Pancake Network is optimally reliable for its number

of edges and nodes.

Page 51: Andrew’s Leap  2011

Mutation Distance One

Can flip any consecutive subsequence

TGCGTCCA

TGCCCTGA

Page 52: Andrew’s Leap  2011

Mutation Distance Three!!!

Transforming cabbage into turnip: polynomial algorithm for sorting signed permutations by

reversals.

Sridhar Hannenhalli      Pavel A. Pevzner  Journal of the ACM 1999

 

Page 53: Andrew’s Leap  2011

One “Simple” Problem

A host of problems

and applications

at the frontiers of

science