# hw1(4) - CS 373U Combinatorial Algorithms Spring 2004...

This preview shows pages 1–4. Sign up to view the full content.

CS 373U: Combinatorial Algorithms, Spring 2004 Homework 1 Due Monday, February 9, 2004 at noon Name: Net ID: Alias: Name: Net ID: Alias: Name: Net ID: Alias: For this and all following homeworks, groups of up to three people can turn in a single solution. Please write all your names and NetIDs on every page you turn in. # 1 2 3 4 5 6 * Total Score Grader

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

View Full Document
CS 373U Homework 1 (due Monday 9, 2004 at noon) Spring 2004 1. Some graphics hardware includes support for an operation called blit , or bl ock t ransfer, which quickly copies a rectangular chunk of a pixelmap (a two-dimensional array of pixel values) from one location to another. This is a two-dimensional version of the standard C library function memcpy() . Suppose we want to rotate an n × n pixelmap 90 clockwise. One way to do this is to split the pixelmap into four n/ 2 × n/ 2 blocks, move each block to its proper position using a sequence of Fve blits, and then recursively rotate each block. Alternately, we can Frst recursively rotate the blocks and blit them into place afterwards. C A B D C A B D C A B D Two algorithms for rotating a pixelmap. Black arrows indicate blitting the blocks into place. White arrows indicate recursively rotating the blocks. The following sequence of pictures shows the Frst algorithm (blit then recurse) in action. In the following questions, assume n is a power of two. (a) Prove that both versions of the algorithm are correct. [Hint: If you exploit all the available symmetries, your proof will only be a half of a page long.] (b) Exactly how many blits does the algorithm perform? (c) What is the algorithm’s running time if each k × k blit takes O ( k 2 ) time? (d) What if each k × k blit takes only O ( k ) time? 1
CS 373U Homework 1 (due Monday 9, 2004 at noon) Spring 2004 2. The traditional Devonian/Cornish drinking song “The Barley Mow” has the following pseu- dolyrics 1 , where container [ i ] is the name of a container that holds 2 i ounces of beer. 2 BarleyMow ( n ): “Here’s a health to the barley-mow, my brave boys,” “Here’s a health to the barley-mow!” “We’ll drink it out of the jolly brown bowl,” “Here’s a health to the barley-mow!” “Here’s a health to the barley-mow, my brave boys,” “Here’s a health to the barley-mow!” for i 1 to n “We’ll drink it out of the container [ i ] , boys,” “Here’s a health to the barley-mow!” for

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 10/14/2011 for the course ECON 101 taught by Professor Smith during the Spring '11 term at West Virginia University Institute of Technology.

### Page1 / 5

hw1(4) - CS 373U Combinatorial Algorithms Spring 2004...

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

View Full Document
Ask a homework question - tutors are online