

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Material Type: Assignment; Class: Theory of Computation; Subject: Computer Science; University: University of Illinois - Urbana-Champaign; Term: Spring 2002;
Typology: Assignments
1 / 3
This page cannot be seen from the preview
Don't miss anything!


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.
(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.
(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?
1
2
3
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).
uses only regular comparators, it always terminate, and the output network is equivalent to the input network).
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.
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.
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 >.