hw_03 - CS 473: Fundamental Algorithms, Spring 2012...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: CS 473: Fundamental Algorithms, Spring 2012 Homework 3 (due Tuesday, 23:55:00, February 14, 2012) Collaboration Policy & submission guidelines: See homework 1. Each student individually have to also do quiz 3 online. Version: 1.0 1. ( 30 pts. ) Saving the world, one pancake at a time. Suppose we have a stack of n pancakes of different sizes. We want to sort the pancakes so that the smaller pancakes are on top of the larger pancakes. The only operation we can perform is a flip- insert a spatula under the top k pancakes, for some k between 1 and n , and flip them all over. (A) ( 15 pts. ) Describe an algorithm to sort an arbitrary stack of n pancakes and give a bound on the number of flips that the algorithm makes. Assume that the pancake information is given to you in the form of an n element array A . A [ i ] is a number between 1 and n and A [ i ] = j means that the j th smallest pancake is in position i from the bottom; in other words A [1] is the size of the bottom most pancake (relative to the...
View Full Document

This note was uploaded on 04/02/2012 for the course CS 473 taught by Professor Chekuri,c during the Spring '08 term at University of Illinois, Urbana Champaign.

Page1 / 2

hw_03 - CS 473: Fundamental Algorithms, Spring 2012...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online