Homework 1 for Combinatorial Algorithms - Fall 2002 | CS 373, Assignments of Computer Science

Material Type: Assignment; Class: Theory of Computation; Subject: Computer Science; University: University of Illinois - Urbana-Champaign; Term: Spring 2002;

Typology: Assignments

Pre 2010

Uploaded on 03/16/2009

koofers-user-7fo-1
koofers-user-7fo-1 🇺🇸

5

(1)

10 documents

1 / 3

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CS 373 Homework 1 (due 01/29/2002) Spring 2002
CS 373: Combinatorial Algorithms, Spring 2002
Homework 1, due January 29 23:59:59, 2002
Name:
Net ID: Alias:
Name:
Net ID: Alias:
Name:
Net ID: Alias:
Starting with Homework 1, homeworks may be done in teams of up to three people. Each team
turns in just one solution, and every member of a team gets the same grade. Since graduate
students are required to solve problems that are worth extra credit for undergraduate students,
grad students may not be on the same team as undergraduates.
Neatly print your name (rst name rst, with no comma), your network ID, and a short alias into
the boxes above.
Do not sign your name. Do not write your Social Security number.
Staple
this sheet of paper to the top of your homework.
Grades will be listed on the course web site by alias give us, so your alias should not resemble your
name or your Net ID. If you don't give yourself an alias, we'll give you one that you won't like.
Required Problems
1.
[10 Points]
(Based on CLRS 27.1-2 and 27.1-4, or CLR 28.1-2 and 28.1-4)
(a)
[5 Points]
Let
n
be an exact power of 2. Show how to construct an
n
-input,
n
-output
comparison network of depth lg
n
in which the top output wire always carries the mini-
mum input value and the bottom output wire always carries the maximum input value.
(b)
[5 Points]
Prove that any sorting network on
n
inputs has depth at least lg
n
.
2.
[10 Points]
(Based on CLRS 27.1-8 or CLR 28.1-8)
Suppose that in addition to the standard kind of comparator, we introduce an "upside-
down" comparator that produces its minimum output on the bottom wire and its maximum
output on the top wire.
1
pf3

Partial preview of the text

Download Homework 1 for Combinatorial Algorithms - Fall 2002 | CS 373 and more Assignments Computer Science in PDF only on Docsity!

CS 373: Combinatorial Algorithms, Spring 2002

Homework 1, due January 29 23:59:59, 2002

Name:

Net ID: Alias:

Name:

Net ID: Alias:

Name:

Net ID: Alias:

Starting with Homework 1, homeworks may be done in teams of up to three people. Each team turns in just one solution, and every member of a team gets the same grade. Since graduate students are required to solve problems that are worth extra credit for undergraduate students, grad students may not be on the same team as undergraduates.

Neatly print your name ( rst name rst, with no comma), your network ID, and a short alias into the boxes above. Do not sign your name. Do not write your Social Security number. Staple this sheet of paper to the top of your homework.

Grades will be listed on the course web site by alias give us, so your alias should not resemble your name or your Net ID. If you don't give yourself an alias, we'll give you one that you won't like.

Required Problems

  1. [10 Points] (Based on CLRS 27.1-2 and 27.1-4, or CLR 28.1-2 and 28.1-4)

(a) [5 Points] Let n be an exact power of 2. Show how to construct an n-input, n-output comparison network of depth lg n in which the top output wire always carries the mini- mum input value and the bottom output wire always carries the maximum input value. (b) [5 Points] Prove that any sorting network on n inputs has depth at least lg n.

  1. [10 Points] (Based on CLRS 27.1-8 or CLR 28.1-8) Suppose that in addition to the standard kind of comparator, we introduce an "upside- down" comparator that produces its minimum output on the bottom wire and its maximum output on the top wire.

(a) [6 Points] An n-input sorting network with m comparators, is represented by a list of m pairs of integers in the range from 1 to n. Thus, a comparator between the wire i and j is represented as (i, j). If i < j then this is a regular comparator, and if i > j it is an upside-down comparator. Describe an algorithm that converts a sorting network with n inputs, c upside-down gates and m overall gates into an equivalent sorting network that uses only regular gates. How fast is your algorithm?

a 1 b

a 2

a 3

a 4

b

b

1

2

3

b 4

Suppose in the comparison network above, all comparators are regular ones ex- cept the rightmost one, which is an upside-down comparator. This comparison network is represented as the following: (1, 2), (3, 4), (1, 3), (2, 4), (3, 2).

(b) [4 Points] Prove that your algorithm is correct (i.e., it indeed outputs a network that

uses only regular comparators, it always terminate, and the output network is equivalent to the input network).

  1. [10 Points] (Based on CLRS 27.2-5 or CLR 28.2-5)

Prove that an n-input sorting network must contain at least one comparator between the ith and (i + 1 )st lines for all i = 1, 2, ..., n − 1.

  1. [10 Points] (Based on CLRS 27.5-1 and 27.5-2, or CLR 28.5-1 and 28.5-2)

The sorting network SORTER[n] was present in class (it is also shown in CLRS Figure 27.12 or CLR Figure 28.12), where n is an exact power of 2. Answer the following questions about SORTER[n].

(a) [5 Points] Give a tight bound for the number of comparators in SORTER[n]. (b) [5 Points] Show that the depth of SORTER[n] is exactly (lg n)(lg n + 1 )/2.

  1. [10 Points] (Based on CLRS 27.5-3 or CLR 28.5-3)

Suppose that we have 2n elements < a 1 , a 2 , ..., a2n > and wish to partition them into the the n smallest and the n largest. Prove that we can do this in constant additional depth after separately sorting < a 1 , a 2 , ..., an > and < an+ 1 , an+ 2 , ..., a2n >.