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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T18:25:38+00:00 2026-06-08T18:25:38+00:00

What data structure supports the following set operations efficiently both in time and space?

  • 0

What data structure supports the following set operations efficiently both in time and space?

  1. union
  2. difference
  3. ismemberof
  4. add
  5. delete

I can think of 3 different ways to do these operations, suppose that we have two sets, their sizes are both N:

Bit Array:

1. O(N)  2.O(N)  3.O(1)  4.O(1)  5.O(1)

HashTable:

1. O(N)  2.O(N)  3.O(1)  4.O(1)  5.O(1)

Ordered Tree:

1. O(NlogN)  2.O(NlogN)  3.O(logN)  4.O(logN)  5.O(logN)

Bit Array and HashTable are fast but they use too much memory, Ordered Tree is slow but consumes less memory.

Please note: the set may contain other types except integer, such as float number or string

What other data structures are both fast and general, and space efficient?

  • 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-08T18:25:39+00:00Added an answer on June 8, 2026 at 6:25 pm

    One option is to augment your ordered tree with a bloom filter to speed up the ismemberof type tests.

    I think that the overall behaviour would be something like:

    1. O(N log(N) )  2. O( ? )  3.O(1)  4.O(log(N))  5.O( log(N) )
    

    However the exact details will depend on the size of the filter, the size of your sets and the size of your domain.

    Another option may be Judy Arrays. I’ve heard good things about them for this kind of use, but have no personal experience.

    Yet another option is a forrest approach (rather than a pure binary tree).

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

Sidebar

Related Questions

I need a data-structure, which supports the following operations both memory and time-efficient, it
I need to design a data structure that supports the following operations: search element
I need a data structure which will support the following operations in a performant
Can someone tell me which data structure supports insert/delete/maximum operation in O(1)?
In my current project, I need following type of data structure Map<String, Map<String,Set<String>>, Set<subscriber>>
I need a data structure that holds unique values (like a set), but also
I have the following data structure: P_ID EVSSMIN EVSSMAX TDMIN TDMAX WARD SYRINGE_ID COMBINE_WITH
I have the following data structure (an atomic vector?) output from daply in plyr
I have the following data structure: [DataServiceEntity] public class User { public string RowKey
Is there a data structure like a queue which also supports removal of elements

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.