Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction to Wireless and Mobile Systems

Authors: Dharma P. Agrawal, Qing An Zeng

4th edition

1305087135, 978-1305087132, 9781305259621, 1305259629, 9781305537910 , 978-130508713

More Books

Students also viewed these Programming questions