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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T17:46:09+00:00 2026-05-22T17:46:09+00:00

Let us have some sequence A, {-1, 3, 2, 5} for example. We can

  • 0

Let us have some sequence A, {-1, 3, 2, 5} for example. We can select all its non-empty subsequences using iterations (binary incrementing some iterator) 1 .. 2^|A|:

int i, A[] = {-1, 3, 2, 5};

for (i = 1; i < (1 << sizeof(A)); i++)
{
  int t = i, p = 0;

  while (t > 0)
  {
    if (t % 2 > 0)
      printf("%d\t", a[p]);

    t /= 2, p++;
  }

  printf("\n");
}

But what should we do if A contains, for example, 5000000 elements? E.g. how to handle 5-billion-bit number?

  • 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-22T17:46:10+00:00Added an answer on May 22, 2026 at 5:46 pm

    Well there is an inerestign set of algorithms that perform such tasks called “Enumeration algorithms”. They deal mainly which questions such as:
    1. What is the ith non-empty subset of all subsets ?
    2. Given a non empty subset, what is the next element ? or previous
    3. Given a non empty subset, what is the rank of this subset ?

    All these operations are performed with linear time. In case you want to obtain all subsets, then you will need to do backtracing.

    An interesting book that deals with these issues is: Combinatorial Algorithms, Generation, Enumeration, Search By K. Rossen.
    I have also a set of slides on this topic, I dont know how to attach them though. Check Lucia Moura website, course Combinatorial Algorithms.

    (if you need details of any of these algorithms above, let me know please)

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

Sidebar

Related Questions

Suppose I have some code: let listB = [ 1; 2; 3 ] Using
Like the Delicious submission bookmark-let, I'd like to have some standard JavaScript I can
Let's assume I have some method that executes CLI application. For example: public string
Let's say I have some code like this: <html> <head><title>Title</title></head> <body> <?php if (!$someCondition){
Let's say I have some pointers called: char * pChar; int * pInt; I
Let's say I have some code like this if(isset($_GET['foo'])) //do something if(isset($_GET['bar'])) //do something
Let's say I have some XML like this <channel> <item> <title>This is title 1</title>
Let's say I have some Java code: public class SomeClass { static { private
Google is failing me on this one. Let's say I have some ECMA script
Let's say I have committed some bad changes to Subversion repository. Then I commit

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.