Question: ---------> hello i need solution for this question please. and also make sure you show me all steps to solve it please. this is from:
---------> hello i need solution for this question please. and also make sure you show me all steps to solve it please.
this is from:
Algorithms and Complexity

3 The Pancake Problem A stack of n pancakes is placed in front of you. You have a spatula which you can insert anywhere into the stack and flip over all the pancakes above the spatula. You want to arrange the pancakes in order of their diameter (they are perfectly round), and you want to use as few flips as possible. As an example suppose n = 6, and the pancakes are numbered 1 through 6 in order of their diameter with 1 the smallest and 6 the largest. Suppose sequence represents the top of the stack. In one flip I can get 643215 (by flipping the first three pancakes: 346), then in the next flip 512346, then 432156, then 123456, so four flips are enough in this case. Let F(n) be the worst case number of flips needed to arrange a stack of n pancakes Find an efficient (in a worst case sense) algorithm for this problem, where efficiency is measured by the worst case number of flips. Remember that your algorithm should work for pancakes with any order. To start you off you should easily be able to show that F(n) is at most 2n. Next, reduce that bound a little more if you can. (Hint: first think about how to move the largest pancake to the bottom..) the original order is 346215, and the left end of the 4 The Glass Jar problem You are doing stress-testing on some kind of glass jars to determine the height from which they can be dropped and sl not break. Here is the setup. You have a ladder with n rungs, and you want to find the highest rung from which you can drop a copy of this jar and not break. We call this the highest safe rung. Obviously, if a jar is not broken in a throwing, it can be reused; otherwise, you have to use a new jar Now you are only given K (identical) jars. For simplicity, supoose K-2 (i.e. you only have two copies of the glass jar). Of course, you can take the simplest way: try throwing one jar from the lowest rung and move one rung up if it does not break. But in the worst case you may need to throw n times, which seems to be not so optimal (note you only use one jar in this case). So our goal is to throw as few times as possible while only using at most K 2 jars. Now your task: describe a strategy for finding the highest safe rung that only uses K2 jars and also minimizes the number of throws in the worst case. Also tell me what is the smallest number of throws you need for the n 100 case (i.e. 100 rungs) 1
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
