hw1 - CS 373 Homework 1(due Spring 1999 CS 373...

Info iconThis preview shows pages 1–3. 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 Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: CS 373 Homework 1 (due 2/9/99) Spring 1999 CS 373: Combinatorial Algorithms, Spring 1999 http://www-courses.cs.uiuc.edu/~cs373 Homework 1 (due February 9, 1999 by noon) Name: Net ID: Alias: Everyone must do the problems marked ◮ . Problems marked a3 are for 1-unit grad students and others who want extra credit. (There’s no such thing as “partial extra credit”!) Unmarked problems are extra practice problems for your benefit, which will not be graded. Think of them as potential exam questions. Hard problems are marked with a star; the bigger the star, the harder the problem. Note: When a question asks you to “give/describe/present an algorithm”, you need to do four things to receive full credit: 1. Design the most efficient algorithm possible. Significant partial credit will be given for less efficient algorithms, as long as they are still correct, well-presented, and correctly analyzed. 2. Describe your algorithm succinctly, using structured English/pseudocode. We don’t want full- fledged compilable source code, but plain English exposition is usually not enough. Follow the examples given in the textbooks, lectures, homeworks, and handouts. 3. Justify the correctness of your algorithm, including termination if that is not obvious. 4. Analyze the time and space complexity of your algorithm. Undergrad/.75U Grad/1U Grad Problems ◮ 1. Consider the following sorting algorithm: STUPIDSORT ( A [0 .. n − 1]) : if n = 2 and A [0] > A [1] swap A [0] ↔ A [1] else if n > 2 m = ⌈ 2 n/ 3 ⌉ STUPIDSORT ( A [0 ..m − 1]) STUPIDSORT ( A [ n − m..n − 1]) STUPIDSORT ( A [0 ..m − 1]) (a) Prove that STUPIDSORT actually sorts its input. (b) Would the algorithm still sort correctly if we replaced m = ⌈ 2 n/ 3 ⌉ with m = ⌊ 2 n/ 3 ⌋ ? Justify your answer. (c) State a recurrence (including the base case(s)) for the number of comparisons executed by STUPIDSORT. 1 CS 373 Homework 1 (due 2/9/99) Spring 1999 (d) Solve the recurrence, and prove that your solution is correct. [Hint: Ignore the ceiling.] Does the algorithm deserve its name? ⋆ (e) Show that the number of swaps executed by STUPIDSORT is at most ( n 2 ) . ◮ 2. 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()...
View Full Document

{[ snackBarMessage ]}

Page1 / 5

hw1 - CS 373 Homework 1(due Spring 1999 CS 373...

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

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