pancakes with a problem! great theoretical ideas in computer science vince conitzer compsci 102 fall...
TRANSCRIPT
![Page 1: Pancakes With A Problem! Great Theoretical Ideas In Computer Science Vince Conitzer COMPSCI 102 Fall 2007 Lecture 1 August 27, 2007 Duke University](https://reader036.vdocuments.us/reader036/viewer/2022081515/56649d955503460f94a7e3b3/html5/thumbnails/1.jpg)
Pancakes With A Problem!Pancakes With A Problem!
Great Theoretical Ideas In Computer ScienceGreat Theoretical Ideas In Computer Science
Vince Vince ConitzerConitzer
COMPSCI 102 Fall COMPSCI 102 Fall 20072007
Lecture 1Lecture 1 August 27, 2007August 27, 2007 Duke UniversityDuke University
![Page 2: Pancakes With A Problem! Great Theoretical Ideas In Computer Science Vince Conitzer COMPSCI 102 Fall 2007 Lecture 1 August 27, 2007 Duke University](https://reader036.vdocuments.us/reader036/viewer/2022081515/56649d955503460f94a7e3b3/html5/thumbnails/2.jpg)
Course StaffCourse Staff
Prof:Prof: Bruce Maggs (Carnegie Bruce Maggs (Carnegie Mellon)Mellon)
TA: Urmi MajumderTA: Urmi Majumder
Lectures developed at Carnegie Lectures developed at Carnegie Mellon, primarily by Prof. Steven Mellon, primarily by Prof. Steven Rudich.Rudich.
![Page 3: Pancakes With A Problem! Great Theoretical Ideas In Computer Science Vince Conitzer COMPSCI 102 Fall 2007 Lecture 1 August 27, 2007 Duke University](https://reader036.vdocuments.us/reader036/viewer/2022081515/56649d955503460f94a7e3b3/html5/thumbnails/3.jpg)
Please feel free to ask questions!
((( )))
![Page 4: Pancakes With A Problem! Great Theoretical Ideas In Computer Science Vince Conitzer COMPSCI 102 Fall 2007 Lecture 1 August 27, 2007 Duke University](https://reader036.vdocuments.us/reader036/viewer/2022081515/56649d955503460f94a7e3b3/html5/thumbnails/4.jpg)
Course DocumentCourse DocumentYou must read this carefully.You must read this carefully.
1.1. Grading formula for the course.Grading formula for the course.1. 40% homework2. 30% quizzes3. 30% final
2.2. Seven points a day late penalty.Seven points a day late penalty.3.3. Collaboration/Cheating PolicyCollaboration/Cheating Policy
1. You may NOT share written work.2. We reuse homework problems.
![Page 5: Pancakes With A Problem! Great Theoretical Ideas In Computer Science Vince Conitzer COMPSCI 102 Fall 2007 Lecture 1 August 27, 2007 Duke University](https://reader036.vdocuments.us/reader036/viewer/2022081515/56649d955503460f94a7e3b3/html5/thumbnails/5.jpg)
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).
I do this by grabbing several from the top and flipping them over,
repeating this (varying the number I flip) as many times as necessary.
![Page 6: Pancakes With A Problem! Great Theoretical Ideas In Computer Science Vince Conitzer COMPSCI 102 Fall 2007 Lecture 1 August 27, 2007 Duke University](https://reader036.vdocuments.us/reader036/viewer/2022081515/56649d955503460f94a7e3b3/html5/thumbnails/6.jpg)
Developing A Notation:Developing A Notation:Turning pancakes into numbersTurning pancakes into numbers
![Page 7: Pancakes With A Problem! Great Theoretical Ideas In Computer Science Vince Conitzer COMPSCI 102 Fall 2007 Lecture 1 August 27, 2007 Duke University](https://reader036.vdocuments.us/reader036/viewer/2022081515/56649d955503460f94a7e3b3/html5/thumbnails/7.jpg)
Developing A Notation:Developing A Notation:Turning pancakes into numbersTurning pancakes into numbers
1
2
3
4
5
![Page 8: Pancakes With A Problem! Great Theoretical Ideas In Computer Science Vince Conitzer COMPSCI 102 Fall 2007 Lecture 1 August 27, 2007 Duke University](https://reader036.vdocuments.us/reader036/viewer/2022081515/56649d955503460f94a7e3b3/html5/thumbnails/8.jpg)
Developing A Notation:Developing A Notation:Turning pancakes into numbersTurning pancakes into numbers
2
3
4
5
1
![Page 9: Pancakes With A Problem! Great Theoretical Ideas In Computer Science Vince Conitzer COMPSCI 102 Fall 2007 Lecture 1 August 27, 2007 Duke University](https://reader036.vdocuments.us/reader036/viewer/2022081515/56649d955503460f94a7e3b3/html5/thumbnails/9.jpg)
Developing A Notation:Developing A Notation:Turning pancakes into numbersTurning pancakes into numbers
52341
![Page 10: Pancakes With A Problem! Great Theoretical Ideas In Computer Science Vince Conitzer COMPSCI 102 Fall 2007 Lecture 1 August 27, 2007 Duke University](https://reader036.vdocuments.us/reader036/viewer/2022081515/56649d955503460f94a7e3b3/html5/thumbnails/10.jpg)
How do we sort this stack?How do we sort this stack?How many flips do we need?How many flips do we need?
52341
![Page 11: Pancakes With A Problem! Great Theoretical Ideas In Computer Science Vince Conitzer COMPSCI 102 Fall 2007 Lecture 1 August 27, 2007 Duke University](https://reader036.vdocuments.us/reader036/viewer/2022081515/56649d955503460f94a7e3b3/html5/thumbnails/11.jpg)
4 Flips Are Sufficient4 Flips Are Sufficient
12345
52341
43215
23415
14325
![Page 12: Pancakes With A Problem! Great Theoretical Ideas In Computer Science Vince Conitzer COMPSCI 102 Fall 2007 Lecture 1 August 27, 2007 Duke University](https://reader036.vdocuments.us/reader036/viewer/2022081515/56649d955503460f94a7e3b3/html5/thumbnails/12.jpg)
Algebraic RepresentationAlgebraic Representation
52341
X = The smallest number of flips required to sort:
? X ?Upper Bound
Lower Bound
![Page 13: Pancakes With A Problem! Great Theoretical Ideas In Computer Science Vince Conitzer COMPSCI 102 Fall 2007 Lecture 1 August 27, 2007 Duke University](https://reader036.vdocuments.us/reader036/viewer/2022081515/56649d955503460f94a7e3b3/html5/thumbnails/13.jpg)
Algebraic RepresentationAlgebraic Representation
52341
X = The smallest number of flips required to sort:
? X 4Upper Bound
Lower Bound
![Page 14: Pancakes With A Problem! Great Theoretical Ideas In Computer Science Vince Conitzer COMPSCI 102 Fall 2007 Lecture 1 August 27, 2007 Duke University](https://reader036.vdocuments.us/reader036/viewer/2022081515/56649d955503460f94a7e3b3/html5/thumbnails/14.jpg)
4 Flips Are Necessary4 Flips Are Necessary
52341
41325
14325
Flip 1 has to put 5 on bottom
Flip 2 must bring 4 to top.
![Page 15: Pancakes With A Problem! Great Theoretical Ideas In Computer Science Vince Conitzer COMPSCI 102 Fall 2007 Lecture 1 August 27, 2007 Duke University](https://reader036.vdocuments.us/reader036/viewer/2022081515/56649d955503460f94a7e3b3/html5/thumbnails/15.jpg)
? X 4Lower Bound
![Page 16: Pancakes With A Problem! Great Theoretical Ideas In Computer Science Vince Conitzer COMPSCI 102 Fall 2007 Lecture 1 August 27, 2007 Duke University](https://reader036.vdocuments.us/reader036/viewer/2022081515/56649d955503460f94a7e3b3/html5/thumbnails/16.jpg)
Upper Bound
Lower Bound
4 X 4
X = 4
![Page 17: Pancakes With A Problem! Great Theoretical Ideas In Computer Science Vince Conitzer COMPSCI 102 Fall 2007 Lecture 1 August 27, 2007 Duke University](https://reader036.vdocuments.us/reader036/viewer/2022081515/56649d955503460f94a7e3b3/html5/thumbnails/17.jpg)
55thth Pancake Number Pancake Number
P5 = The number of flips required to sort the
worst case stack of 5 pancakes.
? P5 ?Upper Bound
Lower Bound
![Page 18: Pancakes With A Problem! Great Theoretical Ideas In Computer Science Vince Conitzer COMPSCI 102 Fall 2007 Lecture 1 August 27, 2007 Duke University](https://reader036.vdocuments.us/reader036/viewer/2022081515/56649d955503460f94a7e3b3/html5/thumbnails/18.jpg)
55thth Pancake Number Pancake Number
P5 = The number of flips required to sort the
worst case stack of 5 pancakes.
4 P5 ?Upper Bound
Lower Bound
![Page 19: Pancakes With A Problem! Great Theoretical Ideas In Computer Science Vince Conitzer COMPSCI 102 Fall 2007 Lecture 1 August 27, 2007 Duke University](https://reader036.vdocuments.us/reader036/viewer/2022081515/56649d955503460f94a7e3b3/html5/thumbnails/19.jpg)
The 5The 5thth Pancake Number: Pancake Number: The MAX of the X’sThe MAX of the X’s
120
1199
32 . . . . . . .
X1 X2 X3 X119 X120
52341
4
![Page 20: Pancakes With A Problem! Great Theoretical Ideas In Computer Science Vince Conitzer COMPSCI 102 Fall 2007 Lecture 1 August 27, 2007 Duke University](https://reader036.vdocuments.us/reader036/viewer/2022081515/56649d955503460f94a7e3b3/html5/thumbnails/20.jpg)
P5 = MAX over s 2 stacks of 5 of MIN # of flips to sort s
120
1199
32 . . . . . . .
X1 X2 X3 X119 X120
52341
4
![Page 21: Pancakes With A Problem! Great Theoretical Ideas In Computer Science Vince Conitzer COMPSCI 102 Fall 2007 Lecture 1 August 27, 2007 Duke University](https://reader036.vdocuments.us/reader036/viewer/2022081515/56649d955503460f94a7e3b3/html5/thumbnails/21.jpg)
Pn
MAX over s stacks of n pancakes of
MIN # of flips to sort s
Or,
The number of flips required to sort a
worst-case stack of n pancakes.
![Page 22: Pancakes With A Problem! Great Theoretical Ideas In Computer Science Vince Conitzer COMPSCI 102 Fall 2007 Lecture 1 August 27, 2007 Duke University](https://reader036.vdocuments.us/reader036/viewer/2022081515/56649d955503460f94a7e3b3/html5/thumbnails/22.jpg)
Be Cool.
Learn Math-speak.
Pn = The number of flips required to sort a worst-case stack of n
pancakes.
![Page 23: Pancakes With A Problem! Great Theoretical Ideas In Computer Science Vince Conitzer COMPSCI 102 Fall 2007 Lecture 1 August 27, 2007 Duke University](https://reader036.vdocuments.us/reader036/viewer/2022081515/56649d955503460f94a7e3b3/html5/thumbnails/23.jpg)
What is Pn for small n?
Can you do n = 0, 1, 2, 3 ?
![Page 24: Pancakes With A Problem! Great Theoretical Ideas In Computer Science Vince Conitzer COMPSCI 102 Fall 2007 Lecture 1 August 27, 2007 Duke University](https://reader036.vdocuments.us/reader036/viewer/2022081515/56649d955503460f94a7e3b3/html5/thumbnails/24.jpg)
Initial Values Of Pn
n 0 1 2 3
Pn 0 0 1 3
![Page 25: Pancakes With A Problem! Great Theoretical Ideas In Computer Science Vince Conitzer COMPSCI 102 Fall 2007 Lecture 1 August 27, 2007 Duke University](https://reader036.vdocuments.us/reader036/viewer/2022081515/56649d955503460f94a7e3b3/html5/thumbnails/25.jpg)
PP33 = 3 = 3
11332 requires 3 Flips, hence 2 requires 3 Flips, hence PP33 ¸̧ 3. 3.
ANYANY stack of 3 can be done in stack of 3 can be done in 33 flips. flips.
Get the big one to the bottom (Get the big one to the bottom (·· 2 flips). 2 flips).
Use Use ·· 1 more flip to handle the top two. 1 more flip to handle the top two.
Hence, Hence, PP33 ·· 3. 3.
![Page 26: Pancakes With A Problem! Great Theoretical Ideas In Computer Science Vince Conitzer COMPSCI 102 Fall 2007 Lecture 1 August 27, 2007 Duke University](https://reader036.vdocuments.us/reader036/viewer/2022081515/56649d955503460f94a7e3b3/html5/thumbnails/26.jpg)
nth Pancake Number
Pn = Number of flips required to sort a worst case stack of n
pancakes.
? Pn ?Upper Bound
Lower Bound
![Page 27: Pancakes With A Problem! Great Theoretical Ideas In Computer Science Vince Conitzer COMPSCI 102 Fall 2007 Lecture 1 August 27, 2007 Duke University](https://reader036.vdocuments.us/reader036/viewer/2022081515/56649d955503460f94a7e3b3/html5/thumbnails/27.jpg)
? Pn ?
Take a few minutes to try
and prove bounds on Pn,
for n>3.
![Page 28: Pancakes With A Problem! Great Theoretical Ideas In Computer Science Vince Conitzer COMPSCI 102 Fall 2007 Lecture 1 August 27, 2007 Duke University](https://reader036.vdocuments.us/reader036/viewer/2022081515/56649d955503460f94a7e3b3/html5/thumbnails/28.jpg)
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 29: Pancakes With A Problem! Great Theoretical Ideas In Computer Science Vince Conitzer COMPSCI 102 Fall 2007 Lecture 1 August 27, 2007 Duke University](https://reader036.vdocuments.us/reader036/viewer/2022081515/56649d955503460f94a7e3b3/html5/thumbnails/29.jpg)
Upper Bound On PUpper Bound On Pnn::Bring To Top Method For n Bring To Top Method For n
PancakesPancakesIf n=1, no work - we are done.If n=1, no work - we are done.
Else: Else: flip pancake n to topflip pancake n to top and then and then flip it to position nflip it to position n..
Now use: Now use: Bring To Top Method Bring To Top Method For n-1 PancakesFor n-1 Pancakes
Total Cost: at most 2(n-1) = 2n –2 flips.
![Page 30: Pancakes With A Problem! Great Theoretical Ideas In Computer Science Vince Conitzer COMPSCI 102 Fall 2007 Lecture 1 August 27, 2007 Duke University](https://reader036.vdocuments.us/reader036/viewer/2022081515/56649d955503460f94a7e3b3/html5/thumbnails/30.jpg)
Better Upper Bound On PBetter Upper Bound On Pnn::Bring To Top Method For n Bring To Top Method For n
PancakesPancakesIf n=2, use one flip and we are done.If n=2, use one flip and we are done.
Else: flip pancake n to top and then Else: flip pancake n to top and then flip it to position n.flip it to position n.
Now use: Now use: Bring To Top Method Bring To Top Method For n-1 PancakesFor n-1 Pancakes
Total Cost: at most 2(n-2) + 1 = 2n –3 flips.
![Page 31: Pancakes With A Problem! Great Theoretical Ideas In Computer Science Vince Conitzer COMPSCI 102 Fall 2007 Lecture 1 August 27, 2007 Duke University](https://reader036.vdocuments.us/reader036/viewer/2022081515/56649d955503460f94a7e3b3/html5/thumbnails/31.jpg)
Bring to top not always optimal Bring to top not always optimal for a particular stackfor a particular stack
5 flips, but can be done in 4 flips5 flips, but can be done in 4 flips
32145
52341
23145
41325
14325
![Page 32: Pancakes With A Problem! Great Theoretical Ideas In Computer Science Vince Conitzer COMPSCI 102 Fall 2007 Lecture 1 August 27, 2007 Duke University](https://reader036.vdocuments.us/reader036/viewer/2022081515/56649d955503460f94a7e3b3/html5/thumbnails/32.jpg)
? Pn 2n - 3
What bounds can you prove on
Pn?
![Page 33: Pancakes With A Problem! Great Theoretical Ideas In Computer Science Vince Conitzer COMPSCI 102 Fall 2007 Lecture 1 August 27, 2007 Duke University](https://reader036.vdocuments.us/reader036/viewer/2022081515/56649d955503460f94a7e3b3/html5/thumbnails/33.jpg)
9
16
Breaking Apart ArgumentBreaking Apart Argument
Suppose a stack S contains a pair Suppose a stack S contains a pair of adjacent pancakes that will not of adjacent pancakes that will not be adjacent in the sorted stack. be adjacent in the sorted stack.
Any sequence of flips that sorts Any sequence of flips that sorts stack S must involve one flip that stack S must involve one flip that inserts the spatula between that inserts the spatula between that pair and breaks them apart. pair and breaks them apart.
![Page 34: Pancakes With A Problem! Great Theoretical Ideas In Computer Science Vince Conitzer COMPSCI 102 Fall 2007 Lecture 1 August 27, 2007 Duke University](https://reader036.vdocuments.us/reader036/viewer/2022081515/56649d955503460f94a7e3b3/html5/thumbnails/34.jpg)
916
Breaking Apart ArgumentBreaking Apart Argument
Suppose a stack S contains a pair Suppose a stack S contains a pair of adjacent pancakes that will not of adjacent pancakes that will not be adjacent in the sorted stack. be adjacent in the sorted stack.
Any sequence of flips that sorts Any sequence of flips that sorts stack S must involve one flip that stack S must involve one flip that inserts the spatula between that inserts the spatula between that pair and breaks them apart. pair and breaks them apart.
Furthermore, this same principle is Furthermore, this same principle is true of the “pair” formed by the true of the “pair” formed by the bottom pancake of S and the plate.bottom pancake of S and the plate.
![Page 35: Pancakes With A Problem! Great Theoretical Ideas In Computer Science Vince Conitzer COMPSCI 102 Fall 2007 Lecture 1 August 27, 2007 Duke University](https://reader036.vdocuments.us/reader036/viewer/2022081515/56649d955503460f94a7e3b3/html5/thumbnails/35.jpg)
n n P Pnn
Suppose n is even. Suppose n is even.
Such a stack S contains n Such a stack S contains n pairs that must be broken pairs that must be broken apart during any apart during any sequence that sorts stack sequence that sorts stack S.S.
2468..n1357..
n-1
S
![Page 36: Pancakes With A Problem! Great Theoretical Ideas In Computer Science Vince Conitzer COMPSCI 102 Fall 2007 Lecture 1 August 27, 2007 Duke University](https://reader036.vdocuments.us/reader036/viewer/2022081515/56649d955503460f94a7e3b3/html5/thumbnails/36.jpg)
n n P Pnn
2
1
S
Detail: This construction only works when n>2
Suppose n is even. Suppose n is even.
Such a stack S contains n Such a stack S contains n pairs that must be broken pairs that must be broken apart during any apart during any sequence that sorts stack sequence that sorts stack S.S.
![Page 37: Pancakes With A Problem! Great Theoretical Ideas In Computer Science Vince Conitzer COMPSCI 102 Fall 2007 Lecture 1 August 27, 2007 Duke University](https://reader036.vdocuments.us/reader036/viewer/2022081515/56649d955503460f94a7e3b3/html5/thumbnails/37.jpg)
n n P Pnn1357..n2468..
n-1
S
Suppose n is odd. Suppose n is odd.
Such a stack S contains n Such a stack S contains n pairs that must be broken pairs that must be broken apart during any apart during any sequence that sorts stack sequence that sorts stack S.S.
![Page 38: Pancakes With A Problem! Great Theoretical Ideas In Computer Science Vince Conitzer COMPSCI 102 Fall 2007 Lecture 1 August 27, 2007 Duke University](https://reader036.vdocuments.us/reader036/viewer/2022081515/56649d955503460f94a7e3b3/html5/thumbnails/38.jpg)
n n P Pnn
1
3
2
S
Detail: This construction only works when n>3
Suppose n is odd. Suppose n is odd.
Such a stack S contains n Such a stack S contains n pairs that must be broken pairs that must be broken apart during any apart during any sequence that sorts stack sequence that sorts stack S.S.
![Page 39: Pancakes With A Problem! Great Theoretical Ideas In Computer Science Vince Conitzer COMPSCI 102 Fall 2007 Lecture 1 August 27, 2007 Duke University](https://reader036.vdocuments.us/reader036/viewer/2022081515/56649d955503460f94a7e3b3/html5/thumbnails/39.jpg)
n ≤ Pn ≤ 2n – 3 (for n ≥ 3)
Bring To Top is within a factor
of two of optimal!
![Page 40: Pancakes With A Problem! Great Theoretical Ideas In Computer Science Vince Conitzer COMPSCI 102 Fall 2007 Lecture 1 August 27, 2007 Duke University](https://reader036.vdocuments.us/reader036/viewer/2022081515/56649d955503460f94a7e3b3/html5/thumbnails/40.jpg)
So starting from ANY stack we can get to
the sorted stack using no more than Pn
flips.
n ≤ Pn ≤ 2n – 3 (for n ≥ 3)
![Page 41: Pancakes With A Problem! Great Theoretical Ideas In Computer Science Vince Conitzer COMPSCI 102 Fall 2007 Lecture 1 August 27, 2007 Duke University](https://reader036.vdocuments.us/reader036/viewer/2022081515/56649d955503460f94a7e3b3/html5/thumbnails/41.jpg)
From ANY stack to sorted stack in · Pn.
Reverse the sequences we use
to sort.
From sorted stack to ANY stack in · Pn ?
((( )))
![Page 42: Pancakes With A Problem! Great Theoretical Ideas In Computer Science Vince Conitzer COMPSCI 102 Fall 2007 Lecture 1 August 27, 2007 Duke University](https://reader036.vdocuments.us/reader036/viewer/2022081515/56649d955503460f94a7e3b3/html5/thumbnails/42.jpg)
From ANY stack to sorted stack in · Pn.
From sorted stack to ANY stack in · Pn.
Hence,
From ANY stack to ANY stack in · 2Pn.
![Page 43: Pancakes With A Problem! Great Theoretical Ideas In Computer Science Vince Conitzer COMPSCI 102 Fall 2007 Lecture 1 August 27, 2007 Duke University](https://reader036.vdocuments.us/reader036/viewer/2022081515/56649d955503460f94a7e3b3/html5/thumbnails/43.jpg)
From ANY stack to ANY stack in · 2Pn.
Can you find a faster way
than 2Pn flips to go from
ANY to ANY?
((( )))
![Page 44: Pancakes With A Problem! Great Theoretical Ideas In Computer Science Vince Conitzer COMPSCI 102 Fall 2007 Lecture 1 August 27, 2007 Duke University](https://reader036.vdocuments.us/reader036/viewer/2022081515/56649d955503460f94a7e3b3/html5/thumbnails/44.jpg)
From ANY Stack S to ANY stack T in · Pn
Rename the pancakes in S to be 1,2,3,..,n. Rewrite T using the new naming scheme that you used for S. T will be some list: (1),(2),..,(n). The sequence of flips that brings the sorted stack to (1),(2),..,(n) will bring S to T.
S: 4,3,5,1,2
T: 5,2,4,3,1
1,2,3,4,5 3,5,1,2,4
![Page 45: Pancakes With A Problem! Great Theoretical Ideas In Computer Science Vince Conitzer COMPSCI 102 Fall 2007 Lecture 1 August 27, 2007 Duke University](https://reader036.vdocuments.us/reader036/viewer/2022081515/56649d955503460f94a7e3b3/html5/thumbnails/45.jpg)
The Known Pancake NumbersThe Known Pancake Numbers
112233445566778899
1010111112121313
0011334455
n Pn
778899
10101111131314141515
![Page 46: Pancakes With A Problem! Great Theoretical Ideas In Computer Science Vince Conitzer COMPSCI 102 Fall 2007 Lecture 1 August 27, 2007 Duke University](https://reader036.vdocuments.us/reader036/viewer/2022081515/56649d955503460f94a7e3b3/html5/thumbnails/46.jpg)
PP1414 Is Unknown Is Unknown
14! Orderings of 14 pancakes.14! Orderings of 14 pancakes.
14! = 87,178,291,20014! = 87,178,291,200
![Page 47: Pancakes With A Problem! Great Theoretical Ideas In Computer Science Vince Conitzer COMPSCI 102 Fall 2007 Lecture 1 August 27, 2007 Duke University](https://reader036.vdocuments.us/reader036/viewer/2022081515/56649d955503460f94a7e3b3/html5/thumbnails/47.jpg)
Is This Really Computer Science?Is This Really Computer Science?
![Page 48: Pancakes With A Problem! Great Theoretical Ideas In Computer Science Vince Conitzer COMPSCI 102 Fall 2007 Lecture 1 August 27, 2007 Duke University](https://reader036.vdocuments.us/reader036/viewer/2022081515/56649d955503460f94a7e3b3/html5/thumbnails/48.jpg)
Posed in Amer. Math. Monthly 82 (1) (1975), “Harry Dweighter” a.k.a. Jacob Goodman
![Page 49: Pancakes With A Problem! Great Theoretical Ideas In Computer Science Vince Conitzer COMPSCI 102 Fall 2007 Lecture 1 August 27, 2007 Duke University](https://reader036.vdocuments.us/reader036/viewer/2022081515/56649d955503460f94a7e3b3/html5/thumbnails/49.jpg)
(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 50: Pancakes With A Problem! Great Theoretical Ideas In Computer Science Vince Conitzer COMPSCI 102 Fall 2007 Lecture 1 August 27, 2007 Duke University](https://reader036.vdocuments.us/reader036/viewer/2022081515/56649d955503460f94a7e3b3/html5/thumbnails/50.jpg)
(15/14)n Pn (5n+5)/3
H. Heydari & Ivan H. Sudborough.
On the Diameter of the Pancake
Network.
Journal of Algorithms, vol 25, pp 67-94,
1997.
![Page 51: Pancakes With A Problem! Great Theoretical Ideas In Computer Science Vince Conitzer COMPSCI 102 Fall 2007 Lecture 1 August 27, 2007 Duke University](https://reader036.vdocuments.us/reader036/viewer/2022081515/56649d955503460f94a7e3b3/html5/thumbnails/51.jpg)
PermutationPermutation
Any particular ordering of all n Any particular ordering of all n elements of an n element set S is elements of an n element set S is called a called a permutationpermutation on the set S. on the set S.
Example:Example: S = {1, 2, 3, S = {1, 2, 3, 4, 5}4, 5}
Example permutation:Example permutation: 5 3 2 4 1 5 3 2 4 1
120 possible permutations on S120 possible permutations on S
![Page 52: Pancakes With A Problem! Great Theoretical Ideas In Computer Science Vince Conitzer COMPSCI 102 Fall 2007 Lecture 1 August 27, 2007 Duke University](https://reader036.vdocuments.us/reader036/viewer/2022081515/56649d955503460f94a7e3b3/html5/thumbnails/52.jpg)
PermutationPermutation
Any particular ordering of all n Any particular ordering of all n elements of an n element set S is elements of an n element set S is called a called a permutationpermutation on the set S. on the set S.
Each different stack of n pancakes is Each different stack of n pancakes is one of the permutations on [1..n].one of the permutations on [1..n].
![Page 53: Pancakes With A Problem! Great Theoretical Ideas In Computer Science Vince Conitzer COMPSCI 102 Fall 2007 Lecture 1 August 27, 2007 Duke University](https://reader036.vdocuments.us/reader036/viewer/2022081515/56649d955503460f94a7e3b3/html5/thumbnails/53.jpg)
Representing A PermutationRepresenting A Permutation
We have many choices of how to specify a We have many choices of how to specify a permutation on S. Here are two methods:permutation on S. Here are two methods:
1)1) List a sequence of all elements of [1..n], List a sequence of all elements of [1..n], each one written exactly once. each one written exactly once. Ex: 6 4 5 2 1 3Ex: 6 4 5 2 1 3
2)2) Give a function Give a function on S s.t. on S s.t. (1) (1) (2) (2) (3) .. (3) .. (n) (n) is a sequence listing [1..n], each one exactly is a sequence listing [1..n], each one exactly once.once.
Ex: Ex: (1)=6 (1)=6 (2)=4 (2)=4 (3) = 5 (3) = 5 (4) = 2 (4) = 2 (4) = 1 (4) = 1 (6) =3(6) =3
![Page 54: Pancakes With A Problem! Great Theoretical Ideas In Computer Science Vince Conitzer COMPSCI 102 Fall 2007 Lecture 1 August 27, 2007 Duke University](https://reader036.vdocuments.us/reader036/viewer/2022081515/56649d955503460f94a7e3b3/html5/thumbnails/54.jpg)
A Permutation is a NOUNA Permutation is a NOUN
An ordering S of a stack of pancakes An ordering S of a stack of pancakes is a permutation. is a permutation.
![Page 55: Pancakes With A Problem! Great Theoretical Ideas In Computer Science Vince Conitzer COMPSCI 102 Fall 2007 Lecture 1 August 27, 2007 Duke University](https://reader036.vdocuments.us/reader036/viewer/2022081515/56649d955503460f94a7e3b3/html5/thumbnails/55.jpg)
An ordering S of a stack of pancakes is An ordering S of a stack of pancakes is a permutation.a permutation.
We can permute S to obtain a new We can permute S to obtain a new stack S’.stack S’.
PermutePermute also means to rearrange so also means to rearrange so as to obtain a permutation of the as to obtain a permutation of the original.original.
A Permutation is a NOUNA Permutation is a NOUNA Permutation can also be a A Permutation can also be a
VERBVERB
![Page 56: Pancakes With A Problem! Great Theoretical Ideas In Computer Science Vince Conitzer COMPSCI 102 Fall 2007 Lecture 1 August 27, 2007 Duke University](https://reader036.vdocuments.us/reader036/viewer/2022081515/56649d955503460f94a7e3b3/html5/thumbnails/56.jpg)
Permute A Permutation.Permute A Permutation.
I start with a I start with a permutationpermutation S of S of
pancakes. pancakes. I continue to use a flip I continue to use a flip operation to operation to permutepermute
my current my current permutationpermutation, , so as to obtain the so as to obtain the
sorted sorted permutationpermutation..
![Page 57: Pancakes With A Problem! Great Theoretical Ideas In Computer Science Vince Conitzer COMPSCI 102 Fall 2007 Lecture 1 August 27, 2007 Duke University](https://reader036.vdocuments.us/reader036/viewer/2022081515/56649d955503460f94a7e3b3/html5/thumbnails/57.jpg)
Ultra-Useful FactUltra-Useful Fact
There are There are n! = 1*2*3*4*…*nn! = 1*2*3*4*…*n permutations on permutations on nn elements. elements.
Proof: in the first counting lecture.Proof: in the first counting lecture.
![Page 58: Pancakes With A Problem! Great Theoretical Ideas In Computer Science Vince Conitzer COMPSCI 102 Fall 2007 Lecture 1 August 27, 2007 Duke University](https://reader036.vdocuments.us/reader036/viewer/2022081515/56649d955503460f94a7e3b3/html5/thumbnails/58.jpg)
Pancake NetworkPancake Network
This network has n! nodes This network has n! nodes
Assign each node the name of one of Assign each node the name of one of the possible n! stacks of pancakes.the possible n! stacks of pancakes.
Put a wire between two nodes Put a wire between two nodes if they are one flip apart.if they are one flip apart.
![Page 59: Pancakes With A Problem! Great Theoretical Ideas In Computer Science Vince Conitzer COMPSCI 102 Fall 2007 Lecture 1 August 27, 2007 Duke University](https://reader036.vdocuments.us/reader036/viewer/2022081515/56649d955503460f94a7e3b3/html5/thumbnails/59.jpg)
Network For n=3Network For n=3
123
321
213
312
231
132
![Page 60: Pancakes With A Problem! Great Theoretical Ideas In Computer Science Vince Conitzer COMPSCI 102 Fall 2007 Lecture 1 August 27, 2007 Duke University](https://reader036.vdocuments.us/reader036/viewer/2022081515/56649d955503460f94a7e3b3/html5/thumbnails/60.jpg)
Network For n=4Network For n=4
![Page 61: Pancakes With A Problem! Great Theoretical Ideas In Computer Science Vince Conitzer COMPSCI 102 Fall 2007 Lecture 1 August 27, 2007 Duke University](https://reader036.vdocuments.us/reader036/viewer/2022081515/56649d955503460f94a7e3b3/html5/thumbnails/61.jpg)
Pancake Network: Routing Delay Pancake Network: Routing Delay
What is the maximum distance What is the maximum distance between two nodes in the pancake between two nodes in the pancake network?network?
Pn
![Page 62: Pancakes With A Problem! Great Theoretical Ideas In Computer Science Vince Conitzer COMPSCI 102 Fall 2007 Lecture 1 August 27, 2007 Duke University](https://reader036.vdocuments.us/reader036/viewer/2022081515/56649d955503460f94a7e3b3/html5/thumbnails/62.jpg)
Pancake Network: ReliabilityPancake Network: Reliability
If up to n-2 nodes get hit by If up to n-2 nodes get hit by lightning the network remains lightning the network remains connected, even though each node connected, even though each node is connected to only n-1 other is connected to only n-1 other nodes. nodes.
The Pancake Network is optimally reliable for its number of edges and
nodes.
![Page 63: Pancakes With A Problem! Great Theoretical Ideas In Computer Science Vince Conitzer COMPSCI 102 Fall 2007 Lecture 1 August 27, 2007 Duke University](https://reader036.vdocuments.us/reader036/viewer/2022081515/56649d955503460f94a7e3b3/html5/thumbnails/63.jpg)
Mutation DistanceMutation Distance
![Page 64: Pancakes With A Problem! Great Theoretical Ideas In Computer Science Vince Conitzer COMPSCI 102 Fall 2007 Lecture 1 August 27, 2007 Duke University](https://reader036.vdocuments.us/reader036/viewer/2022081515/56649d955503460f94a7e3b3/html5/thumbnails/64.jpg)
One “Simple” Problem
A host of problems and applications
at the frontiers of
science
![Page 65: Pancakes With A Problem! Great Theoretical Ideas In Computer Science Vince Conitzer COMPSCI 102 Fall 2007 Lecture 1 August 27, 2007 Duke University](https://reader036.vdocuments.us/reader036/viewer/2022081515/56649d955503460f94a7e3b3/html5/thumbnails/65.jpg)
Study Bee
Definitions of:Definitions of:
nth pancake nth pancake numbernumber
lower boundlower bound
upper boundupper bound
permutationpermutation
Proof of:Proof of:
ANY to ANY in ANY to ANY in ·· P Pnn
![Page 66: Pancakes With A Problem! Great Theoretical Ideas In Computer Science Vince Conitzer COMPSCI 102 Fall 2007 Lecture 1 August 27, 2007 Duke University](https://reader036.vdocuments.us/reader036/viewer/2022081515/56649d955503460f94a7e3b3/html5/thumbnails/66.jpg)
ReferencesReferences
Bill Gates & Christos Papadimitriou: Bounds For Sorting By Prefix Reversal. Discrete Mathematics, vol 27, pp 47-57, 1979.
H. Heydari & H. I. Sudborough: On the Diameter of the Pancake Network. Journal of Algorithms, vol 25, pp 67-94, 1997