Find median of all numbers in the given 500GB file at the command prompt.
File format eg:
12
4
98
3
with one number in each line(numbers can be repeated).Can anyone please help on how to approach on this in JAVA? if we have to split the file and then how can median be calculated? I have come across several posts on median but couldn't find best approach on such huge file .
This doesn't cover the calculation itself, but here is how you read the file in small parts, so that you don't run out of memory.
I recently needed to import a 50mb file that gave me out-of-memory errors with a 2GB memory limit, just because of all the extra metadata that it keeps for each object, and this method helped me get through it.