0% found this document useful (0 votes)
34 views

AAOA Assignment I

This document discusses several problems related to algorithms and data structures: 1. It poses mathematical problems involving logarithms, probability, and summations. 2. It asks to order functions by rate of growth and determine time complexities of search algorithms like sequential and binary search. 3. It provides examples to illustrate different hash table collision resolution strategies like chaining, linear probing, and double hashing when inserting values into a hash table.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views

AAOA Assignment I

This document discusses several problems related to algorithms and data structures: 1. It poses mathematical problems involving logarithms, probability, and summations. 2. It asks to order functions by rate of growth and determine time complexities of search algorithms like sequential and binary search. 3. It provides examples to illustrate different hash table collision resolution strategies like chaining, linear probing, and double hashing when inserting values into a hash table.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Advanced Algorithms and problem solving (CoSc5142)

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.

III. Sequential and binary search


1. Sequential search can also be used for a sorted list. Write an algorithm called
SortedSequentialSearch that will return the same results as the algorithm discussed in
class but will run more quickly because it can stop with a failure the minute it finds that
the target is smaller than the current list value. When you write your algorithm, use the
Compare (x, y) function defined as
The Compare function should be counted as one comparison and can best be used in a
switch. Do an analysis of the worst case, average case with the target found, and average
with the target not found. (Note: This last analysis has many possibilities because of all of
the additional early exits when the target is smaller than the current value.)

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

You might also like