I have an array lets say a = { 1,4,5,6,2,23,4,2};
now I have to find median of array position from 2 to 6 (odd total terms), so what I have done, I have taken a[1]
to a[5]
in arr[0]
to arr[4]
then I have sorted it and write the arr[2]
as the median .
But here every time I put values from one array to another, so that the values of my initial array remains the same. Secondly, I have sorted, so this procedure is taking pretty much **time**
.
So I want to know if there is any way I can do this differently to reduce my computation time
.
Any websites, material to understand, what, and how to do?