AAOA Assignment I
AAOA Assignment I
Group Assignment I
To be submitted 17/5/2011
I. Mathematical Background
1. Typical calculators have the ability to calculate natural logs (to the base e) and logs base
10. How would you use a calculator with just these capabilities to calculate log27 59?
2. Assume that we have a fair five-sided die with the numbers 1 through 5 on its sides. What
is the probability that each of the numbers 1 through 5 will be rolled? If we roll two of
these dice, what is the range of possible totals of the values showing on the two dice? What
is the chance that each of these totals will be rolled?
3. Assume we have a fair eight-sided die with the numbers 1, 2, 3, 3, 4, 5, 5, 5 on its sides.
What is the probability that each of the numbers 1 through 5 will be rolled? If we roll two
of these dice, what is the range of possible totals of the values showing on the two dice?
What is the chance that each of the numbers in this range will be rolled?
4. For the following summations, give an equivalent equation without the summation:
II. Rate of growth
1. List the following functions from highest to lowest order. If any are of the same order,
circle them on your list
2. For each of the following pairs of functions f (n) and g(n), either f (n)=O(g(n)) or
g(n)=O( f (n)), but not both. Determine which is the case.
2. The analysis of binary search in chapter-2 assumed that the size was always
2k -1 for some value of k. For this question, we will explore other possibilities for the size:
A. What is the worst case when N ≠ 2k-1?
B. What is the average case when N ≠ 2k-1, assuming that the key is in
the list? Hint: Think about what this change in size means for the bottom
of the search tree.
C. What is the average case when N ≠ 2k-1, if the key might not be in the
list? Hint:Think about what this change in size means for the bottom of
the search tree.
IV. Hash Table
1. Given the values {2341, 4234, 2839, 430, 22, 397, 3920}, a hash table of size 7, and hash
function h(x) = x mod 7, show the resulting tables after inserting the values in the given
order with each of these collision strategies.
A. Chaining
B. Linear probing
C. double hashing with second hash function h'(x) = (2x - 1) mod 7