Which of the following algorithms finds the average of the largest and smallest integers in a list of n integers (n ≥ 1)? Initialize variables max and min to the first element of the list. Iterate over the list and update max and min as necessary. Return the average of max and min. Sort the list in non-decreasing order. Return the average of the first and last elements of the sorted list. Create a new list consisting of the largest and smallest integers in the original list. Return the average of the two elements in the new list. Initialize variables max and min to 0 and infinity, respectively. Iterate over the list and update max and min as necessary. Return the average of max and min.
-
Which of the following
algorithms finds the average of the largest and smallest integers in a list of n integers (n ≥ 1)?Initialize variables max and min to the first element of the list. Iterate over the list and update max and min as necessary. Return the average of max and min.
Sort the list in non-decreasing order. Return the average of the first and last elements of the sorted list.
Create a new list consisting of the largest and smallest integers in the original list. Return the average of the two elements in the new list.
Initialize variables max and min to 0 and infinity, respectively. Iterate over the list and update max and min as necessary. Return the average of max and min.
Trending now
This is a popular solution!
Step by step
Solved in 3 steps