My question is regarding data from a large file.
I have a huge file which is in this format - Primary_key Value( Eg: 10000001 1 10000002 5 10000009 200 etc. I want to find the values corresponding to the k - large elements in the primary_key column. For ex: If k=2, it should output 200 and 5 as per above example.
As it is a very large file, I was planning on using min heap method and I understand that pretty well. However, my data is in a key-value pair and I don't know how I can use that in the min heap sorting.
Any suggestions on how I can achieve this. Greatly appreciate any help on this.
yes your approach is right, you can use priority queue(with min heap) to achieve this. you can store your data in a map, then use it in priority queue like below.