Could someone do 5a,5b,5c please? We have said that the average number of compar
ID: 3690572 • Letter: C
Question
Could someone do 5a,5b,5c please?
We have said that the average number of comparisons need to find a target value in an n-element list using sequential search is slightly higher than n/2. In this problem, we find an exact expression for this average.
A. Suppose the list has an odd number of items,say 15. At what position is the middle item? Using sequential search, how many comparisons are required to find the middle item? Repeat this exercise with a few more odd numbers until you can do the following: If there are n items in the list and n is an odd number, write an expression for the number of comparisons required to find the middle item.
B. Suppose the list has an even number of items, say 16. At what position are the two "middle" items? Using sequential search, how many comparisons are required to find each of these? What are the average of these two numbers? Repeat this exercise with a few more even numbers until you can do the following: If there are n items in the list and n is an even number, write an expression for the number of comparisons required to find the two middle items.
C. Noting that half the items in a list fall before the midpoint and half after the midpoint, use your answer to parts a and b to write an exact expression for the average number of comparisons done using sequential search to find a target value that occurs in an n-element list.
Explanation / Answer
questions are not there