In Segment 18.7, we said that a sequential search of an array will examine on average

Chapter 18, Problem 13

(choose chapter or problem)

In Segment 18.7, we said that a sequential search of an array will examine on average about half of the n entries. Lets look a little more carefully at this computation. A sequential search is either successful or not. Let be the probability that we will find the desired value in the array and 1 - be the probability that we will not. We further assume that the value, if found, is equally likely to be in each of the locations of the array. We need to consider each possibility. For each case, we count the comparisons and determine its probability of occurrence. To find the average number of comparisons made by the search, we first multiply each probability by the number of comparisons in each case. The following table summarizes these results: Probability Number of Comparisons Product Found at index 0 Found at index 1 Found at index 2 ... Found at index n - 2 Found at index n - 1 Not found / n / n / n ... / n / n 1 1 2 3 ... n 1 n n / n 2 / n 3 / n ... (n 1) / n (1 ) n a. Compute the average number of comparisons by adding all the products in the last column of the table.b. What is the average number of comparisons if the search is guaranteed to be successful ( = 1)?c. What is the average number of comparisons if the search is guaranteed to be unsuccessful ( = 0)?d. What is the average number of comparisons if the search is successful half of the time ( = 0.5)?

Unfortunately, we don't have that question answered yet. But you can get it answered in just 5 hours by Logging in or Becoming a subscriber.

Becoming a subscriber
Or look for another answer

×

Login

Login or Sign up for access to all of our study tools and educational content!

Forgot password?
Register Now

×

Register

Sign up for access to all content on our site!

Or login if you already have an account

×

Reset password

If you have an active account we’ll send you an e-mail for password recovery

Or login if you have your password back