Karanbir S.

asked • 03/24/21

What does each line of code does? For example: static private float Median(float[] array) //method heading for the Median method

static private float Median(float[] array) 

{

float[] tempArray = array;

int count = tempArray.Length;

Array.Sort(tempArray);

float medianValue = 0;

if (count % 2 == 0)

{

float middleElement1 = tempArray[(count / 2) - 1];

float middleElement2 = tempArray[(count / 2)];

medianValue = (middleElement1 + middleElement2) / 2;

}

else

{

medianValue = tempArray[(count / 2)];

}


return medianValue;

}



1 Expert Answer

By:

Patrick B. answered • 03/24/21

Tutor
4.7 (31)

Math and computer tutor/teacher

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.