largest 30 elements using binary search

how to find the 30 largest elements through the txt file using binary search?
I should find 30 largest elements from txt file and then store it in array
> using binary search
no, try again.
What's the memory limit? If you don't care about how much memory it uses you just can read all the elements inside an array, sort the array then the last 30 elements are the biggest ones.
The standard library has a "binary search": http://www.cplusplus.com/reference/algorithm/binary_search/
It seems to:
test if value exists in sorted sequence


Some terms used by standard library are a bit ambiguous, but yes, binary search is not your solution.


You obviously have to read every value from the file. The question is what to do with them? Keep? Discard? All? Some? 30 largest?

The values that you keep, should they be in a sorted container? If yes, how and why to store sorted values?
Topic archived. No new replies allowed.