Docsity

CS 473UG Homework Problem Set 1 - Spring 2006, Assignments of Algorithms and Programming

Toggle sidebar
bg1
Homework Problem Set 1
CS 473UG โ€“ Spring 2006
Assigned On: January 31, 2006
Due On: February 7, 2006
Instructions: Solve these problems in groups of size at most 3. Solution to each problem must be on a
separate sheet; this assists us greatly in grading the problems.
Recommended Reading: Chapter 4 of the textbook and lecture notes on the web.
Problem 1 Solve problem 4.26 from the class textbook.
Problem 2 Consider a data structure for Union-Find that performs path compression in find as
discussed in class. Starting from makeUnionFind(S), show that any sequence of mun ion and find
operations, where all the uni on operations appear before any of the find operations, takes O(m) time.
Problem 3 As observed in section 4.8 of the textbook, there are situations where we would like to
modify the code for an alphabet, and communicate the new code over a channel. This problem is about
how one can represent a Huffman Code as a bit string.
Assume that the alphabet is S={0,1,2,...n โˆ’1}. Show that the optimal prefix code for alphabet S
can be represented using 2nโˆ’1 + nโŒˆlog nโŒ‰bits. Note: It is possible that a symbol in Sis encoded using
O(n) bits in the optimal prefix code. (Can you think of an example?) So just sending the code of each
symbol will not be efficient.
1

Partial preview of the text

Download CS 473UG Homework Problem Set 1 - Spring 2006 and more Assignments Algorithms and Programming in PDF only on Docsity!

Homework Problem Set 1

CS 473UG โ€“ Spring 2006

Assigned On: January 31, 2006 Due On: February 7, 2006

Instructions: Solve these problems in groups of size at most 3. Solution to each problem must be on a separate sheet; this assists us greatly in grading the problems.

Recommended Reading: Chapter 4 of the textbook and lecture notes on the web.

Problem 1 Solve problem 4.26 from the class textbook.

Problem 2 Consider a data structure for Union-Find that performs path compression in find as discussed in class. Starting from makeUnionFind(S), show that any sequence of m union and find operations, where all the union operations appear before any of the find operations, takes O(m) time.

Problem 3 As observed in section 4.8 of the textbook, there are situations where we would like to modify the code for an alphabet, and communicate the new code over a channel. This problem is about how one can represent a Huffman Code as a bit string.

Assume that the alphabet is S = { 0 , 1 , 2 ,... n โˆ’ 1 }. Show that the optimal prefix code for alphabet S can be represented using 2n โˆ’ 1 + nโŒˆlog nโŒ‰ bits. Note: It is possible that a symbol in S is encoded using O(n) bits in the optimal prefix code. (Can you think of an example?) So just sending the code of each symbol will not be efficient.