Presentation is loading. Please wait.

Presentation is loading. Please wait.

Andrew’s Leap 2011 Pancakes With A Problem Steven Rudich.

Similar presentations


Presentation on theme: "Andrew’s Leap 2011 Pancakes With A Problem Steven Rudich."— Presentation transcript:

1

2 Andrew’s Leap 2011

3 Pancakes With A Problem Steven Rudich

4 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.

5 Developing A Notation: Turning pancakes into numbers

6 1 2 3 4 5

7 2 3 4 5 1

8 5234152341

9 So how many flips to sort this particular stack? 5234152341

10 4 Flips Are Sufficient 1234512345 5234152341 4321543215 2341523415 1432514325

11 Algebraic Representation 5234152341 X = The smallest number of flips required to sort: ?  X  ? Upper Bound Lower Bound

12 Algebraic Representation 5234152341 X = The smallest number of flips required to sort: ?  X  4 Upper Bound Lower Bound

13 Algebraic Representation 5234152341 X = The smallest number of flips required to sort: 1  X  4 Upper Bound Lower Bound

14 Algebraic Representation 5234152341 X = The smallest number of flips required to sort: 2  X  4 Upper Bound Lower Bound

15 Algebraic Representation 5234152341 X = The smallest number of flips required to sort: 3  X  4 Upper Bound Lower Bound

16 4 Flips Are Necessary 5234152341 4132541325 1432514325 Flip 1 has to put 5 on bottom. Flip 2 must bring 4 to top.

17 Algebraic Representation 5234152341 X = The smallest number of flips required to sort: 4  X  4 Upper Bound Lower Bound

18 Upper Bound Lower Bound 4  X  4 X = 4

19 5 th Pancake Number P 5 = The number of flips required to sort the worst case stack of 5 pancakes. ?  P 5  ? Upper Bound Lower Bound

20 5 th Pancake Number P 5 = The number of flips required to sort the worst case stack of 5 pancakes. 4  P 5  ? Upper Bound Lower Bound

21 The 5 th Pancake Number: The MAX of the X’s 120120 1 199199 32....... X1X1 X2X2 X3X3 X 119 X 120 5234152341 4

22 n th Pancake Number P n = The number of flips required to sort the worst case stack of n pancakes. ?  P n  ? Upper Bound Lower Bound

23 ?  P n  ? What bounds can you prove on P n ?

24 Bring To Top Method Bring biggest to top. Place it on bottom. Bring next largest to top. Place second from bottom. And so on…

25 Upper Bound On P n : Bring To Top Method For n Pancakes If 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.

26 Better Upper Bound On P n : Bring To Top Method For n Pancakes If 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.

27 Bring to top not always optimal for a particular stack 5 flips, but can be done in 4 flips 3214532145 5234152341 2314523145 4132541325 1432514325

28 ?  P n  2n - 3 What bounds can you prove on P n ?

29 9 16 Breaking Apart Argument Suppose 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.

30 9 16 Breaking Apart Argument Suppose 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.

31 n  P n Suppose n is even. S contains n pairs that will need to be broken apart during any sequence that sorts stack S. 2 4 6 8.. n 1 3 5 7.. n-1 S

32 n  P n Suppose n is odd. S contains n pairs that will need to be broken apart during any sequence that sorts stack S. 1 3 5 7.. n 2 4 6 8.. n-1 S Detail: This construction only works when n>3

33 n  P n  2n - 3 Bring To Top is within a factor of two of optimal

34 n  P n  2n - 3 So starting from ANY stack we can get to the sorted stack using no more than P n flips.

35 From ANY stack to Sorted Stack in · P n Can you see why we can get from the Sorted stack to ANY stack in · P n flips? Reverse the sequences we use to sort.

36 From Sorted Stack to ANY stack in · P n Can you see why we can get from ANY stack S to ANY stack T in · P n flips?

37 From ANY Stack S to ANY stack T in P n 4351243512 1435214352 ST

38 From ANY Stack S to ANY stack T in P n RENAME PANCAKES IN YELLOW SO THAT S IS SORTED. THIS FIXES THE YELLOW ORDERING OF THE STACK T. 4351243512 1435214352 4123541235 1234512345 ST

39 The Known Pancake Numbers 1 2 3 4 5 6 7 8 9 10 11 12 13 0134501345 n PnPn 7 8 9 10 11 13 14 15 14 16 15 17 16 18 17 19

40 P 18 Is Unknown 18! Orderings of 18 pancakes. 18! = 6,402,373,705,728,000

41 Burnt Pancake Numbers 1 2 3 4 5 6 7 8 9 10 1 4 6 8 10 12 14 15 17 18 n PnPn

42 Is This Really Computer Science?

43 Posed in Amer. Math. Monthly 82 (1) (1975), “Harry Dweighter” a.k.a. Jacob Goodman

44 (17/16)n  P n  (5n+5)/3 Bill Gates & Christos Papadimitriou: Bounds For Sorting By Prefix Reversal. Discrete Mathematics, vol 27, pp 47-57, 1979.

45 (15/14)n  P n  (5n+5)/3 H. Heydari & H. I. Sudborough: On the Diameter of he Pancake Network. Journal of Algorithms, vol 25, pp 67-94, 1997.

46 P n  18n/11 An (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

47 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.

48 Network For n=3 123123 321321 213213 312312 231231 132132

49 Network For n=4

50 Pancake Network: Message Routing Delay What is the maximum distance between two nodes in the network? PnPn

51 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.

52 Mutation Distance One Can flip any consecutive subsequence TGCGTCCA TGCCCTGA

53 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

54 One “Simple” Problem A host of problems and applications at the frontiers of science


Download ppt "Andrew’s Leap 2011 Pancakes With A Problem Steven Rudich."

Similar presentations


Ads by Google