Select the maximum of 1 billion floating point numbers.

Source: Internet
Author: User

Thought 1:

First, split the data into some files with a small amount of data, such as 1000000 data into one file.

Sort the data of each file (sort by quick sort)

Then, the K-path merge method is used to merge the data into a file, and the maximum 10000 data records sorted are retrieved.

 

Thought 2:
1. Read all the data at a time to obtain the largest and minimum values.
2. Use the maximum and minimum values, which are divided into 100 intervals. DX = (x_max-x_min)/100. -- Range of each interval: DX * (I-1) to DX * I, I = 1 to 100.
3. Read all data at a time and count the number of data falling into each interval.
4. From the maximum interval, add up the number of data in sequence and locate the interval that is exactly greater than 10 thousand.
5. If there are many numbers in this interval, you can subscribe to 100 more intervals for search. If there are not many data, read all the data at a time and queue the number of the size ranges in this interval, find the required number.
6. Read all the data at a time, and obtain the number that exceeds the upper limit of this range.
The number of data found in step 5 and Step 6 is 10 thousand.

Http://blog.csdn.net/laibinghua/article/details/5904636

Http://www.cppblog.com/85940806/archive/2011/06/02/147958.html

Select the maximum of 1 billion floating point numbers.

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.