4/2 + 4/2-1 /2
because of order of operation so is the ((4/2+4/2)-1)/2
which is 2+2-1 which is three then divided by 2.
but that is the first number plus second /2.
not second number +the third one??????
If there are four (4) numbers to be considered, take the 4/2 and 4/2-1, which are
the 2nd and 1st numbers and take the average of them. Remember C and C++
start counting array elements from zero: the 0th, 1st, 2nd, 3rd, 4th, 5th element etc.
so is the fifth number divided by 2 but rounded up the decimal.
so is 5/2 +5/2-1 then divided by 2
so is 2.5 + 1.5/2
but since they rounded up it is 3+2 /2 right?????
The number left of the colon is the index of the number, right of the colon is
the number itself. This array has 5 elements, so 5/2 == 2 so that median is
found at index number 2, which is 30.
For an even number of elements:
0:10
1:20
2:30
3:40
There are four elements so take the average of the numbers at indexes 4/2
and 4/2-1, which are index values 2 and 1 so take the average of 30 and 20
which makes (30+20)/2 == 25.
In general: if n (the number of elements in the array) is odd, take the
element at index value n/2; if n is even take the average of the two numbers
at index positions n/2 and n/2-1. Of course the numbers in the array need
to be sorted, either ascending or descending.
Comment