Next: About this document ...
Homework 2: Asymptotics
Handed out Thursday, September 22. Due at the start of class Tuesday, October 4, 2011 .
- Problem 1.
- Use the formal definitions (not the Limit Rule) to establish the following.
In each case state specific values of the constants (e.g., , ,
) you used to satisfy the conditions, and show how you arrived at
these values. (There are many potentially correct choices. Explaining your work
is thus essential for full credit.)
- (a)
-
- (b)
-
.
- (c)
-
. (Hint: Find such that
, for all .)
- Problem 2.
- Repeat Problem 1, but this time use the Limit Rule to show that each function is in the set given in the problem.
- Problem 3.
- For each pair of expressions below,
indicate whether is , , , , or of
. Note that zero, one or more of these relations may hold for a
given pair; list all correct ones, and explain your work for partial credit.
- Problem 4.
- Consider the following algorithm to sort the array Keys.
for i= 1 to n-1 do
base_j = i;
base_x = Keys[i]
for j = i + 1 to n do
If Keys[j] < base_x then
base_j = j;
base_x = Keys[j];
end forj;
If base_j < > i then
Keys[base_j] = Keys[i];
Keys[i] =base_x;
end fori;
- (a)
- Give a summation for the number of key swaps
in the worst case and simplify your summation.
- (b)
- Give a summation for the number of key swaps
in the best case and simplify your summation.
- (c)
- Give a double summation for the number of comparisons
in the worst case and simplify your summation.
- (d)
- Give a double summation for the number of comparisons
in the best case and simplify your summation.
- (e)
- Give a double summation for the number of comparisons in the average case, but do not solve.
Next: About this document ...
MM Hugue
2011-09-22