
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
Solutions to problems 1-5 from assignment 8 of the theory of algorithms course at princeton university, spring 2005. Topics include hopfield networks, max-cut, and perfect hash functions.
Typology: Exercises
1 / 1
This page cannot be seen from the preview
Don't miss anything!

COS 423 Theory of Algorithms Spring 2005
Answer problems 1–5. Problem 4b is extra credit. This assignment is due Wednesday, May 4 at 12 noon in CS 207. Collaboration is not permitted. You must work entirely on your own except for the following two exceptions (i) you are welcome to consult with course staff members and (ii) you may use any of the course materials. Note that you are not permitted to drop a no-collaboration problem set.
Read Chapter 12 and 13 in Kleinberg-Tardos.
(a) Given a fixed set of m elements S, design an algorithm that finds a perfect hash function in O(m^2 ) expected time. † (b) Given a fixed set of m elements S, design an algorithm that finds a perfect hash function in O(m) expected time and space. Hint: hash into a table of size m, then create m secondary hash tables, one for each chain in the original hash table.
(a) Any comparison-based sorting algorithm must make at least O(n log n) comparisons to sort n elements. (b) Composite is a problem in NP, so it is unlikely that there exists a polynomial-time algorithm for it. (c) 3Color is an NP-complete problem because 3Color is in NP and 3Color polynomial reduces to 3Sat. (d) I just invented a dynamic programming algorithm for the knapsack problem whose running time is O(nW ), where n is the number of items, and all values and weights are integers between 0 and W. Since the knapsack problem is NP-complete and my algorithm’s running time is polynomial in n and W , I’ve proven P = NP.