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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:17:26+00:00 2026-05-25T12:17:26+00:00

Trying to calculate all the subsets ( power set ) of the 9-letter string

  • 0

Trying to calculate all the subsets (power set) of the 9-letter string ‘ABCDEFGHI’.

Using standard recursive methods, my machine hits out of memory (1GB) error before completing. I have no more physical memory.

How can this be done better? Language is no issue and results sent to the standard output is fine as well – it does not need to be held all in memory before outputting.

  • 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-25T12:17:26+00:00Added an answer on May 25, 2026 at 12:17 pm

    There is a trivial bijective mapping from the power set of X = {A,B,C,D,E,F,G,H,I} to the set of numbers between 0 and 2^|X| = 2^9:

    Ø maps to 000000000 (base 2)

    {A} maps to 100000000 (base 2)

    {B} maps to 010000000 (base 2)

    {C} maps to 001000000 (base 2)

    …

    {I} maps to 000000001 (base 2)

    {A,B} maps to 110000000 (base 2)

    {A,C} maps to 101000000 (base 2)

    …

    {A,B,C,D,E,F,G,H,I} maps to 111111111 (base 2)

    You can use this observation to create the power set like this (pseudo-code):

    Set powerset = new Set();
    for(int i between 0 and 2^9)
    {
      Set subset = new Set();
      for each enabled bit in i add the corresponding letter to subset
      add subset to powerset
    }
    

    In this way you avoid any recursion (and, depending on what you need the powerset for, you may even be able to “generate” the powerset without allocating many data structures – for example, if you just need to print out the power set).

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

Sidebar

Related Questions

I'm trying to calculate all the correct answer a user gets and update it
I'm trying to calculate the time it takes to receive all data from a
am trying to calculate mean and variance using 3X3 window over image(hXw) in opencv...here
I'm trying to write this query, that would calculate the average value of all
I'd like to calculate all the permutations of size Y of a set of
I am trying to calculate the average (mean) rating for all entries within a
I'm trying to calculate the median of a set of values, but I don't
In my Rails 3.2.8 application, I'm trying to calculate all of the users products
I am trying to calculate all the primes up to an arbitrary number by
I'm trying to calculate autocorrelation of sample windows in a time series using the

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.