a) Describe an algorithm for locating the last occurrence of the largest number in a list of integers.________________b) Estimate the number of comparisons used.
SOLUTIONStep 1In this problem, we are asked to determine the following.Step 2a).an algorithm for locating the last occurrence of the largest number in a list of integers. Let be the list of n integers.we have to find the last occurrence of the largest integer. We can do this by assigning a variable max and a variable pos for the largest number and its position respectively.We assign max to be the largest integer in the first step and then compare it with the next integer in the given set and if it is found that the new integer is larger than max, then assign that new value as max. In this method, we compare all the integers in the set and the maximum value is found out.