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 280647
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T05:08:11+00:00 2026-05-12T05:08:11+00:00

I have a set of double-precision data and I need their list to be

  • 0

I have a set of double-precision data and I need their list to be always sorted. What is the best algorithm to sort the data as it is being added?

As best I mean least Big-O in data count, Small-O in data count (worst case scenario), and least Small-O in the space needed, in that order if possible.

The set size is really variable, from a small number (30) to lots of data (+10M).

  • 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-12T05:08:11+00:00Added an answer on May 12, 2026 at 5:08 am

    Building a self-balancing binary tree like a red-black tree or AVL tree will allow for Θ(lg n) insertion and removal, and Θ(n) retrieval of all elements in sorted order (by doing a depth-first traversal), with Θ(n) memory usage. The implementation is somewhat complex, but they’re efficient, and most languages will have library implementations, so they’re a good first choice in most cases.

    Additionally, retreiving the i-th element can be done by annotating each edge (or, equivalently, node) in the tree with the total number of nodes below it. Then one can find the i-th element in Θ(lg n) time and Θ(1) space with something like:

    node *find_index(node *root, int i) {
      while (node) {
        if (i == root->left_count)
          return root;
        else if (i < root->left_count)
          root = root->left;
        else {
          i -= root->left_count + 1;
          root = root->right;
        }
      }
      return NULL; // i > number of nodes
    }
    

    An implementation that supports this can be found in debian’s libavl; unfortunately, the maintainer’s site seems down, but it can be retrieved from debian’s servers.

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

Sidebar

Related Questions

I have a set of points on the infinite (well, double precision) 2D plane.
I have a set of numbers with varying precision. I need to create a
I have a set of three double values as part of an anonymous expression
I have two classes set up as follows: class Point { protected: double coords[3];
I have set a background on the data-role=page element like so <div data-role=page style=background:
Is there a way to format a double number that always have n digits
I have a double precision array field dblArrayFld in a table myTable and I'd
I'm using a Table View in a Cocoa application. I have set the double
So I have a double set to equal 1234, I want to move a
I have set some constants. public final double TWO = 50; public final double

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.