1. Which configuration of data in a list causes the smallest number of exchanges in a selection sort? Which configuration of data causes the largest number of exchanges? 2. Explain….
Suggest a modification of the binary search algorithm that emulates this strategy for a list of names.
1. Suppose that a list contains the values
20 44 48 55 62 66 74 88 93 99
at index positions 0 through 9. Trace the values of the variables left, right, and midpoint in a binary search of this list for the target value 90. Repeat for the target value 44.
2. The method we usually use to look up an entry in a phone book is not exactly the same as a binary search because, when using a phone book, we don’t always go to the midpoint of the sublist being searched. Instead, we estimate the position of the target based on the alphabetical position of the first letter of the person’s last name. For example, when we are looking up a number for “Smith,” we look toward the middle of the second half of the phone book first, instead of in the middle of the entire book. Suggest a modification of the binary search algorithm that emulates this strategy for a list of names. Is its computational complexity any better than that of the standard binary search?