1 / 53

Andrew’s Leap 2011

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

myrna
Download Presentation

Andrew’s Leap 2011

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Andrew’s Leap 2011

  2. Steven Rudich Pancakes With A Problem

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

  4. Developing A Notation:Turning pancakes into numbers

  5. Developing A Notation:Turning pancakes into numbers 5 2 3 4 1

  6. Developing A Notation:Turning pancakes into numbers 5 2 3 4 1

  7. Developing A Notation:Turning pancakes into numbers 52341

  8. So how many flips to sort this particular stack? 52341

  9. 4 Flips Are Sufficient 52341 14325 23415 43215 12345

  10. Algebraic Representation 52341 X = The smallest number of flips required to sort: Upper Bound ?  X  ? Lower Bound

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

  12. Algebraic Representation 52341 X = The smallest number of flips required to sort: Upper Bound 1 X  4 Lower Bound

  13. Algebraic Representation 52341 X = The smallest number of flips required to sort: Upper Bound 2 X  4 Lower Bound

  14. Algebraic Representation 52341 X = The smallest number of flips required to sort: Upper Bound 3 X  4 Lower Bound

  15. 4 Flips Are Necessary 52341 14325 41325 Flip 1 has to put 5 on bottom. Flip 2 must bring 4 to top.

  16. Algebraic Representation 52341 X = The smallest number of flips required to sort: Upper Bound 4 X  4 Lower Bound

  17. X = 4 4  X  4 Lower Bound Upper Bound

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

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

  20. The 5th Pancake Number: The MAX of the X’s 1 2 3 52341 199 120 . . . . . . . X1 4 X2 X3 X119 X120

  21. nth Pancake Number Pn = The number of flips required to sort the worst case stack of n pancakes. Upper Bound ?  Pn ? Lower Bound

  22. ?  Pn ? What bounds can you prove on Pn?

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

  24. Upper Bound On Pn: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.

  25. Better Upper Bound On Pn: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.

  26. Bring to top not always optimal for a particular stack • 5 flips, but can be done in 4 flips 52341 14325 41325 23145 32145

  27. ?  Pn 2n - 3 What bounds can you prove on Pn?

  28. Breaking Apart Argument 916 • 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.

  29. Breaking Apart Argument 916 • 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.

  30. n  Pn S 2468..n1357..n-1 • Suppose n is even. S contains n pairs that will need to be broken apart during any sequence that sorts stack S.

  31. n  Pn S 1357..n 2468..n-1 • Suppose n is odd. S contains n pairs that will need to be broken apart during any sequence that sorts stack S. Detail: This construction only works when n>3

  32. n  Pn 2n - 3 Bring To Top is within a factor of two of optimal

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

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

  35. 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?

  36. From ANY Stack StoANY stack Tin Pn S T 14 352 43 512

  37. From ANY Stack Sto ANY stack Tin PnRENAME PANCAKES IN YELLOWSO THAT S IS SORTED. THIS FIXES THE YELLOW ORDERING OF THE STACK T. S T 14 352 41 235 43 512 12 345

  38. 12345678910111213 01345 The Known Pancake Numbers Pn n • 16 • 17 • 18 • 19 7891011131415

  39. P18 Is Unknown • 18! Orderings of 18 pancakes. • 18! = 6,402,373,705,728,000

  40. 12345678910 1 4 6 8 10 12 14 15 17 18 Burnt Pancake Numbers Pn n

  41. Is This Really Computer Science?

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

  43. (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.

  44. (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.

  45. Pn 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

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

  47. Network For n=3 213 123 312 321 132 231

  48. Network For n=4

  49. Pancake Network:Message Routing Delay • What is the maximum distance between two nodes in the network? Pn

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

More Related