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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T20:00:52+00:00 2026-06-08T20:00:52+00:00

Given several sets of elements, e.g.: int set1[5] {5601, 935, 4153, 2195, 422}; int

  • 0

Given several sets of elements, e.g.:

int set1[5] {5601, 935, 4153, 2195, 422};
int set2[5] {5601, 935, 23, 44, 422};
int set3[5] {4205, 935, 4153, 2195, 15};
int set4[5] {4205, 589, 4015, 44, 422};

Where order matters (i.e. 1, 2, 3 is different to 2, 1, 3), what is an efficient algorithm to locate a specific set? E.g., you want to locate:

int value[5] {5601, 935, 23, 44, 422};

Considerations:

  1. Insertion cost for new sets is not an issue, so they can be stored in any data structure, in order to optimize search time.

  2. The sets will contain anywhere between 1 and 1,000,000 elements each (approximately, and there will be anywhere between 1 and 1000 sets (again, approximately). However the number of elements will always be the same for any given set of sets (e.g. if one set has 10 elements, then all sets will have 10 elements).

Follow-up question, I’ll be implementing this in C++ so I’d be interested to find out for any recommended algorithms, whether they exist in an open source C++ library (preferably STL, Boost, or QT, but I’ll consider others too).

  • 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-08T20:00:54+00:00Added an answer on June 8, 2026 at 8:00 pm

    Use a std::vector<set_type> to store the sets. Insert all of the sets into the container. Sort the container using std::sort. Find elements using std::binary_search (or std::lower_bound if you need an iterator to the element).

    The type you use for set_type depends on the number of elements in each set. If the number of elements is known to be small, then std::array<T, N> would be sufficient; otherwise, consider std::vector<T>.

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

Sidebar

Related Questions

Summary: Given an array {a, b, ..., w, x, ..., z} insert several elements
Given several vectors/sets, each of which contains multiple integer numbers which are different within
On any given server there are several sets of config files. Most obviously the
Given: Several million records in a mongo collection. Each record has 10 fields, of
Given a class with several constructors - how can I tell Resolve which constructor
given a plain text document with several lines like: c48 7.587 7.39 c49 7.508
Given remote page: http://example.com/paged_list.aspx which uses a Javascript function call to display several pages
Given client = new XMemcachedClient(server, port); What happens if I have several thread doing
Having tried several solutions to get NHibernate to delete orphan records. Given the following
I have a project where I need to give the users several different sets

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.