Question: Consider the following function that swaps the maximum and the minimum of a vector: void swap_min_max (vector & a) [ int min pos =
Consider the following function that swaps the maximum and the minimum of a vector: void swap_min_max (vector & a) [ int min pos = 0; int max_pos = 0; for (int i = 1; i < a.size(); i++) { if (a[i] < a [min_pos]) (min_pos = i; } } if (a[i] } a [max_pos]) (max_pos = i; } int temp = a [min_pos]; a [min_pos] = a a [max_pos]; a [max_pos] = temp; What best describes the big-Oh efficiency of this algorithm?
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
