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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T12:16:54+00:00 2026-05-11T12:16:54+00:00

I need an algorithm to find all of the subsets of a set where

  • 0

I need an algorithm to find all of the subsets of a set where the number of elements in a set is n.

S={1,2,3,4...n} 

Edit: I am having trouble understanding the answers provided so far. I would like to have step-by-step explanation of how the answers work to find the subsets.

For example,

S={1,2,3,4,5} 

How do you know {1} and {1,2} are subsets?

Could someone help me with a simple function in c++ to find subsets of {1,2,3,4,5}

  • 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. 2026-05-11T12:16:55+00:00Added an answer on May 11, 2026 at 12:16 pm

    It’s very simple to do this recursively. The basic idea is that for each element, the set of subsets can be divided equally into those that contain that element and those that don’t, and those two sets are otherwise equal.

    • For n=1, the set of subsets is {{}, {1}}
    • For n>1, find the set of subsets of 1,…,n-1 and make two copies of it. For one of them, add n to each subset. Then take the union of the two copies.

    Edit To make it crystal clear:

    • The set of subsets of {1} is {{}, {1}}
    • For {1, 2}, take {{}, {1}}, add 2 to each subset to get {{2}, {1, 2}} and take the union with {{}, {1}} to get {{}, {1}, {2}, {1, 2}}
    • Repeat till you reach n
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given a set {1,2,3,4,5...n} of n elements, we need to find all subsets of
I need an algorithm to find out all the possible positions of a group
I need to create an algorithm that could find all the critical paths in
I need an algorithm to find max independent set in a tree. I'm thinking
I need advice or directions on how to write an algorithm which will find
I need an algorithm which given a list L and a number N ,
Minimum Set Cover is a question where you must find the minimum number of
Is there a known algorithm or method to find all complete sub-graphs within a
I need an algorithm for this problem: Given a set of n natural numbers
I'm working on an algorithm to find all paths between two nodes in a

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.