{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

a5solutions

# a5solutions - CS 234 Fall 2010 Assignment 5 Written...

This preview shows pages 1–2. Sign up to view the full content.

CS 234 Fall 2010 Assignment 5 Written Component Solutions 1. Recall that the average-case and worst-case runtimes of binary search are Θ(log n ) . The average-case runtime of interpolation search is Θ(log log n ) (assuming a relatively uniform distribution of keys) but the worst-case runtime is O ( n ) . The algorithms are exactly the same except for the formula used to determine which element to “probe” at each recursive call. PJ Itterp wants to have the both of best worlds by alternating which formula is used. To be more specific, when searching for a given key, the first, third, fifth, etc. recursive calls will use the binary search formula and the second, fourth, sixth, etc. recursive calls will use the interpolation search formula. (a) What is the average-case runtime of PJ Itterp’s algorithm (assume a relatively uniform distribution of keys)? Briefly justify your answer. [2 marks] The average-case can’t be worse than twice that of interpolation search (or binary search for that matter) because half of the calls use the interpolation search formula. Also, it clearly can’t be asymptotically better than that of interpolation search (the algorithm with the asymptotically better average-case runtime). Hence the average case of PJ Itterp’s idea is Θ(log log n ) .

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 3

a5solutions - CS 234 Fall 2010 Assignment 5 Written...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online