About K quantile

Source: Internet
Author: User

For a set containing n elements, the so-called K quantile is to divide the sorted set into k equal-size sets of "K-1 Order Statistics ". Please provide an O (nlgk) time that can be used to obtain the K quantile of a set containing n elements (unordered)Algorithm.

 

Analysis:

K_select (A [n], K)

{

If (k = 0)

Return;

M = bit_select (A [n], 2); // find the median, M is the median, time complexity is O (n)

Divide A [n] into two parts based on M. m exists as an intermediate position, the left side is smaller than m, the right side is greater than m, and O (N)

M1 = k_select (A [1 M-1], K/2 );

M2 = k_select (A [M + 1 ,...... N], K/2 );


}

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.