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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started