Answered step by step
Verified Expert Solution
Question
1 Approved Answer
1. Pancake aesthetics. A diner serves a breakfast plate which simply consists of n pancakes A very bad cook fills the order. He proceeds by
1. Pancake aesthetics. A diner serves a breakfast plate which simply consists of n pancakes A very bad cook fills the order. He proceeds by making n pancakes-all of different sizes and all with one side burnt. He then piles the pancakes onto a plate to create a tower of pancakes. Mr. Waiter picks up the plate and immediately realizes that he has to make the plate presentable. He wants to (i) sort the pancakes from smallest to largest with the largest pancake at the bottom of the plate, and (ii) hide the burnt side of each pancake. Now he only has one move available to him push a spatula underneath one of the pancakes and then flip the entire subtower of pancakes above the spatula upside down. His goal is to use this move repeatedly until his goals are accomplished. How many moves does he need? Let's create a mathematical model for this problem. Represent the ith smallest pancake as i if the pancake has its good side facing up and as -i if its burnt side is facing up Let the array .. .. n] store the pancakes on the plate created by the bad cook. In particular, Plj] refers to the jth pancake from the top. Thus, for n 5 the input array can look like this: P-3, 2,4, -1,-5] Let flip(i), 1 i
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started