Assuming the array x is sorted and is of length n:
If n is odd then the median is x[(n-1)/2].
If n is even than the median is ( x[n/2] + x[(n/2)-1] ) / 2.
More Related Contents:
- Interview question – Search in sorted array X for index i such that X[i] = i
- What's the output of this code written in java?
- Java equivalent to C++ arrow [closed]
- how to replace display array list equals another array list values
- java vs C++ in pre and post increment
- java.lang.arrayoutofboundexception length:10 index:10
- How do i format a ArrayList for printing?
- Finding the max/min value in an array of primitives using Java
- Convert ArrayList to String[] array [duplicate]
- Cannot create an array of LinkedLists in Java…?
- How to convert an int array to String with toString method in Java [duplicate]
- How to find the index of an element in an array in Java?
- Variable length (Dynamic) Arrays in Java
- How to display a svg byte array as an image in a JasperReport?
- ArrayIndexOutOfBoundsException when iterating through all the elements of an array
- How to get unique values from array
- How does the Java array argument declaration syntax “…” work?
- Remove Null Value from String array in java
- Arrays constants can only be used in initializers error
- How does one instantiate an array of maps in Java?
- Arrays with trailing commas inside an array initializer in Java
- What’s the C++ idiom equivalent to the Java static block?
- In Java, remove empty elements from a list of Strings
- get closest value to a number in array
- Wav file convert to byte array in java
- How do you load values into a JTable so that it shows the previous values when the form is opened?
- Trie vs. suffix tree vs. suffix array
- Check if an array is sorted, return true or false
- How can I perform multiplication without the ‘*’ operator?
- Java: Checking equality of arrays (order doesn’t matter)