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

  • Home
  • SEARCH
  • 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 632717
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T20:06:24+00:00 2026-05-13T20:06:24+00:00

This shouldn’t be a difficult question, but I’d just like someone to bounce it

  • 0

This shouldn’t be a difficult question, but I’d just like someone to bounce it off of before I continue. I simply need to decide what data structure to use based on these expected activities:

  1. Will need to frequently iterate through in sorted order (starting at the head).
  2. Will need to remove/restore arbitrary elements from the/a sorted view.
  3. Later I’ll be frequently resorting the data and working with multiple sorted views.
  4. Also later I’ll be frequently changing the position of elements within their sorted views.

This is in Java, by the way.

My best guess is that I’ll either be rolling some custom Linked Hash Set (to arrange the links in sorted order) or possibly just using a Tree Set. But I’m still not completely sure yet. Recommendations?

Edit: I guess because of the arbitrary remove/restore, I should probably stick with a Tree Set, right?

Actually, not necessarily. Hmmm…

  • 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-13T20:06:25+00:00Added an answer on May 13, 2026 at 8:06 pm

    In theory, I’d say the right data structure is a multiway tree – preferably something like a B+ tree. Traditionally this is a disk-based data structure, but modern main memory has a lot of similar characteristics due to layers of cache and virtual memory.

    In-order iteration of a B+ tree is very efficient because (1) you only iterate through the linked-list of leaf nodes – branch nodes aren’t needed, and (2) you get extremely good locality.

    Finding, removing and inserting arbitrary elements is log(n) as with any balanced tree, though with different constant factors.

    Resorting within the tree is mostly a matter of choosing an algorithm that gives good performance when operating on a linked list of blocks (the leaf nodes), minimising the need to use leaf nodes – variants of quicksort or mergesort seem like likely candidates. Once the items are sorted in the branch nodes, just propogate the summary information back through the leaf nodes.

    BUT – pragmatically, this is only something you’d do if you’re very sure that you need it. Odds are good that you’re better off using some standard container. Algorithm/data structure optimisation is the best kind of optimisation, but it can still be premature.

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

Sidebar

Related Questions

This shouldn't be difficult, but I can't add HtmlAgilityPack.dll as a reference in an
I know this shouldn't be done.. but i need the home page to be
This shouldn't be so hard but I just can't seem to get this to
I know this shouldn't be that hard, but I couldn't find the answer on
I'm still fairly new to Java, but I'm fairly sure this shouldn't happen. There's
This really shouldn't be hard, I just can't figure out how to do it.
(Since this is my first SO question, let me just say I hope it's
This sounds like it would be a simple task, but I'm running into some
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
What I understand is that this shouldn't be done, but I believe I've seen

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.