## CPSC 311-501 and CPSC 311-502: Analysis of Algorithms Homework Assignment #6 Spring 2003

### General Guidelines for Homework

• Be clear and precise. Write neatly and legibly. Justify all answers, even if not specified in the question. Use good judgement concerning how detailed to make your answer.
• If the question is not fully specified, you may need to make some assumptions. In this case, you must state any assumptions you make, and justify why they are reasonable.
• Everyone must turn in their own copy of the assignment. You may consult outside material or work with others (this is encouraged), but you must reference your sources (people, books, webpages, etc.). These must be listed on the cover sheet mentioned below.
• All assignments in this course must include a completed and signed coverpage available on the course homepage. Any assignment turned in without a fully completed and signed coverpage will receive ZERO POINTS.

## Assigned Problems

Due: Tuesday March 18, 2003 at the beginning of class

1. Exercise 22.2-3 in the text (p. 539). (5 points)

2. Exercise 22.2-6 in the text (p. 539). (10 points)

3. Exercise 22.4-1 in the text (p. 551). (10 points)

4. Consider the following sequence of makeset, union, and find operations (20 points):
```for i := 1 to n
makeset(i)
for i := 1 to n-1
union( find(i), find(i+1) )
for i := 1 to n
find(i)
```

(a) Analyze the time complexity of the above sequence of operations assuming no heuristics are applied (i.e., no weighted union, and no path compression). Assume union(x,y) always makes x a child of y.

(b) Analyze the time complexity of the above sequence of operations assuming the weighted union heuristic (but not path compression) is applied.

(c) Analyze the time complexity of the above sequence of operations assuming the path compression heuristic (but not weighted union) is applied. Assume union(x,y) always makes x a child of y.

(d) Analyze the time complexity of the above sequence of operations assuming both weighted union heuristic and path compression are applied.

## Bonus Problems

Due by Tuesday April 1, 2003

These problems can be done for extra credit. Points for bonus problems will be tabulated separately, and will be considered separately at the end of the semester.

They should be turned in separately from your regular assignment. They will be accepted upto two weeks past the due date of the assignment.

• Bonus Problem: Exercise 22.4-2 in the text (p. 549). (10 points)