2. If the probability of a successful sequential search is p, then what is the probability of finding the target value at a specific index in the array?
Cavg (n) =
3. For binary search, what is Cbest (n)?
4. For binary search, what is Cworst (n)?
5. For binary search, develop a formula for Cavg (n)? (you do not necessarily need to solve it)
Amortized efficiency/complexity applies to a sequence of operations performed on a data structure. It is useful when the worst case cost for some operation is occasionally expensive, so for a sequence of n such operations the worst case is better than n * (worst case for the operation).
Consider the following simple example. During an experiment, a biologist wants to collect data about n items in real time. Each item has a unique, comparable key associated with it. Later, she will process (call Find) the data for all n items in some random order based on their key.
Her assistant, a struggling CS student, decides that a data structure with two operations is required:
Insert(item) - which must be very fast
Find(key) - called in random order
6. How would you implement (array, linked list, etc.) this data structure?
7. What is the worst-case analysis for all n Inserts followed by all n Finds?
8. Suppose that you have an algorithm that required 10 seconds to run on a problem size of 1000. How long would you expect the algorithm to run on a problem size of 10,000?