Question: Please use code for the part 4 & 5 IV. normalize the list (divide all by the maximum) V. Use the program and insert a

Please use code for the part 4 & 5

IV. normalize the list (divide all by the maximum)

V. Use the program and insert a bubble and merge sort and compare the counter to see which one it is the fastest sorting.

#include

using namespace std;

int largest(int arr[], int n)

{

int i;

// Initialize maximum element

int max = arr[0];

for (i = 1; i < n; i++)

if (arr[i] > max)

max = arr[i];

return max;

}

int smallest(int arr[], int n)

{

int i;

// Initialize minimum element

int min = arr[0];

for (i = 1; i < n; i++)

if (arr[i] < min)

min = arr[i];

return min;

}

double average(int a[], int n)

{

int sum = 0;

for (int i=0; i

sum += a[i];

return (double)sum/n;

}

// Driver Code

int main()

{

int arr[] = {8, 9, 10, 12, 13};

int n = sizeof(arr) / sizeof(arr[0]);

cout << "Largest in given array is " << largest(arr, n);

cout << " Smallest in given array is " << smallest(arr, n);

cout << " Average of given array is " << average(arr, n);

return 0;

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!