B. After you have accomplished the task to part a, you are given another name. How many comparisons are necessary to place this name in its place in the alphabetical list? What is the average or expected number of comparisons?
C. After you have accomplished the task in part a, you are given k more names to put in the list. How many comparisons are necessary? What is the average number of comparisons actually needed?© BrainMass Inc. brainmass.com October 9, 2019, 10:26 pm ad1c9bdddf
A. We can use bubble sort to accomplich this task. First we find the smallest name from n names and it requires n-1 comparisons; Second in the rest n-1 names we find the smallest name and it requires n-2 comparisons. And so on. Finally the total number of comparison is:
(n-1) + (n-2) + ... + 2 + 1 = n(n-1)/2
B. After I have accomplished task of part a, for a ...
The solution examples of determining how many comparisons are necessary to complete given tasks.