Interview questions, give you MB of memory, sort 10 GB files (1 digit per line)

Source: Internet
Author: User
How can we sort 10 GB files (one number per row) in MB of memory? How can I find 10 GB files? How does one calculate the number of times each keyword appears in a 10g File? How does one sort 10G files by MB in memory (one number per line? How can I find 10 GB files? How to calculate the number of times each keyword appears in a 10 GB file

Reply content:

How can we sort 10 GB files (one number per row) in MB of memory? How can I find 10 GB files? How to calculate the number of times each keyword appears in a 10 GB file

Use time for space
The specific implementation is to load files in batches and then calculate

Java? using nio and mapreduce

Not understandPhpBut I am familiar with reading this question.
Let's talk about the idea.
1. implementation of sorting
This is a typical topic of standalone external sorting. The specific method isSort parts firstThenMerge multiple channelsOutput file.
2. search
If the file cannot be processed, you can only traverse and search for the file.
If the file can be processed, the file has been sorted and can be processed.Binary search.
3. Statistics
If the file cannot be processed, there is still no good way to traverse it.
If the order has been sorted, you can directly perform binary search. Search for the number at the specified position.

Let's take a look at the book "programming Pearl", which seems to be a problem.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.