Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

****MUST WORK WITH FOLLOWING INPUT***: C++ ******************* #include const double EPS = 0.00001; int array[] = {1,5,7,4,2,6,3,9,8}; double result = findMedian(array, 9); ASSERT_TRUE(fabs(result-5.0) < EPS);

****MUST WORK WITH FOLLOWING INPUT***: C++ *******************

#include const double EPS = 0.00001; int array[] = {1,5,7,4,2,6,3,9,8}; double result = findMedian(array, 9); ASSERT_TRUE(fabs(result-5.0) < EPS);

************************************************

Write a function called findMedian that takes two parameters - an array of int and the size of the array. The function should return the median of the array, which will require sorting the array (you can use the built-in sort function from the examples). This will change the original array, but that's okay for this assignment. If you're not familiar with calculating the median, please look that up. Remember that it's different for odd and even groups of values. If you are testing your code by calling it from a different file, remember to have a function prototype for findMedian in that file.

The file must be named: findMedian.cpp.

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

Students also viewed these Databases questions