Pancakes With A Problem!Magic Trick At 3:00pm Sharp!Course StaffSlide 4Course Document You must read this carefully.My Low Vision and You.Slide 7Slide 8Developing A Notation: Turning pancakes into numbersSlide 10Slide 11Slide 12How do we sort this stack? How many flips do we need?4 Flips Are SufficientAlgebraic RepresentationSlide 164 Flips Are NecessarySlide 18Slide 195th Pancake NumberSlide 21The 5th Pancake Number: The MAX of the X’sP5 = MAX over s2 stacks of 5 of MIN # of flips to sort sPn = MAX over s2 stacks of n pancakes of MIN # of flips to sort sSlide 25Pn = The number of flips required to sort a worst-case stack of n pancakes.What is Pn for small n?Initial Values Of Pn.P3 = 3nth Pancake Number? Pn ?Bring To Top MethodUpper Bound On Pn: Bring To Top Method For n PancakesBetter Upper Bound On Pn: Bring To Top Method For n PancakesBring to top not always optimal for a particular stack? Pn 2n - 3Breaking Apart ArgumentSlide 38n PnSlide 40Slide 41Slide 42n Pn 2n – 3 for n¸ 3n Pn 2n - 3From ANY stack to sorted stack in · Pn.Slide 46From ANY stack to ANY stack in · 2Pn.From ANY Stack S to ANY stack T in · PnThe Known Pancake NumbersP14 Is UnknownIs This Really Computer Science?Slide 52(17/16)n Pn (5n+5)/3(15/14)n Pn (5n+5)/3PermutationSlide 56Representing A PermutationA Permutation is a NOUNA Permutation is a NOUN. A permutation can also be a VERB.Permute A Permutation.There are n! = 1*2*3*4*…*n permutations on n elements.Pancake Network: Definition For n! NodesNetwork For n=3Network For n=4Pancake Network: Message Routing DelayPancake Network: ReliabilityMutation DistanceOne “Simple” ProblemStudy BeeSlide 70High Level PointReferencesPancakes With A Problem!Pancakes With A Problem!Great Theoretical Ideas In Computer ScienceGreat Theoretical Ideas In Computer ScienceSteven Steven RudichRudichCS 15-251 Spring CS 15-251 Spring 20042004Lecture 1Lecture 1Jan 13, 2004Jan 13, 2004Carnegie Mellon Carnegie Mellon UniversityUniversityMagic Trick At 3:00pm Sharp!Magic Trick At 3:00pm Sharp! Be punctual.Be punctual.Sit close-up: some of the tricks Sit close-up: some of the tricks are hard to see from the back.are hard to see from the back.Course StafCourse StafProfs:Profs:Steven RudichSteven RudichAnupam GuptaAnupam GuptaTAs:TAs:Yinmeng ZhangYinmeng ZhangBella VoldmanBella VoldmanBrendan JubaBrendan JubaAndrew GilpinAndrew GilpinSusmit SarkarSusmit SarkarAdam WiermanAdam WiermanPlease feel free to ask questions! ((( )))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% quizes3. 30% final2.2.Seven points a day late penalty.Seven points a day late penalty.3.3.Collaboration/Cheating PolicyCollaboration/Cheating Policy1. You may NOT share written work.2. We reuse homework problems.My Low Vision and You.My Low Vision and You.I have a genetic retinal condition called I have a genetic retinal condition called Stargardt’s disease. My central vision is Stargardt’s disease. My central vision is going, one pixel at a time, to zero. I have going, one pixel at a time, to zero. I have working peripheral vision.working peripheral vision.I can’t recognize faces – so please I can’t recognize faces – so please introduce yourself to me every time!introduce yourself to me every time!I detect motion really well so please move I detect motion really well so please move your hand when you raise it in class.your hand when you raise it in class.Pancakes With A Problem!Pancakes With A Problem!Great Theoretical Ideas In Computer ScienceGreat Theoretical Ideas In Computer ScienceSteven Steven RudichRudichCS 15-251 Spring CS 15-251 Spring 20042004Lecture 1Lecture 1Jan 13, 2004Jan 13, 2004Carnegie Mellon Carnegie Mellon UniversityUniversityThe chef at our place is sloppy, and when he prepares a stack of pancakes they come out all diferent 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.Developing A Notation:Developing A Notation:Turning pancakes into numbersTurning pancakes into numbersDeveloping A Notation:Developing A Notation:Turning pancakes into numbersTurning pancakes into numbers12345Developing A Notation:Developing A Notation:Turning pancakes into numbersTurning pancakes into numbers23451Developing A Notation:Developing A Notation:Turning pancakes into numbersTurning pancakes into numbers52341How do we sort this stack?How do we sort this stack?How many flips do we need?How many flips do we need?523414 Flips Are Sufficient4 Flips Are Sufficient1234552341432152341514325Algebraic RepresentationAlgebraic Representation52341X = The smallest number of flips required to sort:? X ?Upper BoundLower BoundAlgebraic RepresentationAlgebraic Representation52341X = The smallest number of flips required to sort:? X 4Upper BoundLower Bound4 Flips Are Necessary4 Flips Are Necessary523414132514325Flip 1 has to put 5 on bottomFlip 2 must bring 4 to top.? X 4Lower BoundUpper BoundLower Bound4 X 4X = 455thth Pancake Number Pancake NumberP5 = The number of flips required to sort the worst case stack of 5 pancakes.? P5 ?Upper BoundLower Bound55thth Pancake Number Pancake NumberP5 = The number of flips required to sort the worst case stack of 5 pancakes.4 P5 ?Upper BoundLower BoundThe 5The 5thth Pancake Number: Pancake Number: The MAX of the X’sThe MAX of the X’s120119932. . . . . . . X1X2X3X119X120523414P5 = MAX over s2 stacks of 5 of MIN # of flips to sort s120119932. . . . . . . X1X2X3X119X120523414Pn = MAX over s2 stacks of n pancakes of MIN # of flips to sort sPn = The number of flips required to sort the worst-case stack of n pancakes.Pn = MAX over s2 stacks of n pancakes of MIN # of flips to sort sPn = The number of flips required to sort a worst-case stack of n pancakes.Be Cool.Learn Math-speak.Pn = The number of flips required to sort a worst-case stack of n pancakes.What is Pn for small n?Can you do n= 0,1,2, 3 ?Initial Values Of Pn.n 0 1 2 3Pn0 0 1 3PP33 = 3 = 311332 requires 3 Flips, hence 2 requires 3 Flips, hence PP33 ¸¸ 3. 3.ANYANY stack of 3 can be
View Full Document