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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T22:13:37+00:00 2026-06-01T22:13:37+00:00

I am designing an algorithm that works as follows: Suppose that there are N

  • 0

I am designing an algorithm that works as follows:

Suppose that there are N slots which are initially empty and each
slot is numbered uniquely.

As time goes by, items will arrive and get deposited into slots whose numbers match
the items’ numbers. However, the order in which items arrive are assumed to
be at random.

In the meanwhile, a merging algorithm will be regularly executed to merge adjacent occupied slots in such a way that the slots will grow more and more “connected” as time goes by and eventually become one large occupied slot, at which point the algorithm terminates.

P.S. my algorithm is serial. The merging part is activated regularly after a certain number
of new slots are occupied.

  • 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-06-01T22:13:39+00:00Added an answer on June 1, 2026 at 10:13 pm

    You are probably looking for something based on disjoint-set.

    Start with n sets, each for an empty slot, and “merge” [union] them once you fill two adjacent slots. This can be done by maintaining “highest” and “lowest” field in each root of each set.

    Once you enter an element, you need to find its root [easy to do with this data structure], and merge it with set[root.highest+1] and with set[root.lowest-1] – if they are both already “filled”.

    Each merge will also have to modify the root.highest and root.lowest fields, but that can be easily done in O(1), once you have found the new root.

    If you implement the disjoint set as forests, initialization time of the algorithm is O(n) [where n is the number of slots], and each insertion op is O(alpha(n)) where alpha(n) is the inverse ackerman function, which is sub-logarithmic.

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

Sidebar

Related Questions

Im designing a dialerPad form using Windows form, there is a textbox which should
I need help designing an algorithm for recommendations on movies. Every user in the
While designing a table my colleague here says that I should avoid identity column
When designing a collection class, is there any reason not to implement locking privately
In designing any desktop applications, are there any general rules on how much memory
I'm in startup of designing a client/server audio system which can stream audio arbitrarily
I'm designing a piece of a game where the AI needs to determine which
I'm designing a CUDA app to process some video. The algorithm I'm using calls
My first post here – hoping you can help me with designing an algorithm
Here is my problem: I am designing an application that will allow students to

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.