Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3238868
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T17:54:12+00:00 2026-05-17T17:54:12+00:00

For a sequence of values, how would one find the sorted middle 50% of

  • 0

For a sequence of values, how would one find the sorted middle 50% of the sequence in Boost Accumulators?

For example, let’s say that I have the following sequence,
25, 21, 9, 13, 17, 19, 12, 29, 50, 97, 10, 11.

The middle 50% data I would like to have is as follows:
13, 17, 19, 21.

Of course, one can sort the sequence, which now becomes
9, 10, 11, 12, 13, 17, 19, 21, 25, 29, 50, 97.

And then one can collect the middle 50% data.

Now, does the Accumulators framework internally store and sort the sequence? If yes, is it possible to retrieve the value that reside in a particular index?

Reading from here, I think the Accumulators framework does not store the original data and this framework is not appropriate for the problem I am trying to solve.

While writing this, I find it a bit foolish to try to accomplish this using Accumulators. However, I was using it for other purposes and I was expecting a solution in Accumulators.

Now, is it possible to build a data structure that efficiently maintain a current and sorted middle 50% data in a way that the size of the data structure almost never exceeds the half of the size of the sequence?

Thinking about it for a while, I guess it may not be possible to devise such a data structure. At the first thought, I thought that some of the values can be forgotten/discarded permanently assuming they will never appear in the sorted middle 50%. However, this assumption is probably wrong, and some values might reappear in the sorted middle 50% depending on the yet to arrive values in the sequence.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T17:54:13+00:00Added an answer on May 17, 2026 at 5:54 pm

    As @Adam Rosenfeld pointed out, you’re looking for Hoare’s selection algorithm, which is a variant of the Quick Sort.

    What he didn’t point out is that with a bit of care, you can have it put the elements you care about in the right place as part of the selection process.

    The selection algorithm partitions the data into those less than and those greater than the selected element. For example, assume you had an array of 100 elements, and you wanted the 25th. It would arrange the elements so the first through 24th elements in the array were smaller than the 25th, then would be the 25th, then the larger elements. Those on each side are only ordered with respect to that one element though, not compared to each other.

    You can still take advantage of that to get the middle 50% quickly: first select the 25th percentile. Then specify only the part above the 25th as input, and find the element 2/3rds of the way across that part. That will give you the 25th, the 75th, and (the important part) all of the elements whose values are between those will also be arranged between those elements (though inside of that range, the order will be basically random).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I have a sequence of values (e.g., 3, 5, 8, 12, 15)
Lets say we have the following set of numbers representing values over time 1
I have a sequence of migrations in a rails app which includes the following
In my rails app, i have the following function in one of my controller
I find that one of the most interesting features of both Haskell and Perl6
I have the following (imperative) algorithm that I want to implement in Haskell: Given
I have a sequence of integers (positive and negative) like this one: 12,-54,32,1,-2,-4,-8,12,56,-22,-21,4,17,35 And
Earlier this week I ask a question about filtering out duplicate values in sequence
I am displaying a fixed sequence in the tree list along with some values
I know how to fill an std::vector with non-trivial initial values, e.g. sequence numbers:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.