Skip to main content

Questions tagged [powerset]

A powerset is the set of all subsets for a given set.

powerset
1 vote
2 answers
72 views

Powerset where each element can be either "positive" or "negative"

I'm looking for a simple way to generate the powerset of an iterable where each element can be "positive" or "negative", but not both in the same combination. There are no ...
upe's user avatar
  • 2,016
0 votes
1 answer
51 views

Constructing a modified powerset in Rust - filtering out certain subsets based on their content

What is the most efficient way (and/or most idiomatic) to make a modified powerset of vector of 2-tuples in Rust? By modified, what I mean is the following rule (a,b),(c,b) not in any set, for any a,b,...
Karl's user avatar
  • 97
-4 votes
2 answers
75 views

Powerset of a list with equal elements in Java [closed]

Chat-GPT generated me the following code in Java, but it still doesn't work with equal elements. The supposed output is incorrect, since the equal elements get simply ignored and I can't figure out ...
Eugen's user avatar
  • 252
1 vote
1 answer
114 views

Haskell Power Set Function

I get an error: working.hs:186:25: error: * Couldn't match expected type: Set (Set a) with actual type: [[a]] * In the expression: union (map (insert x) (powerSet s)) (powerSet s) ...
fistic iasi's user avatar
0 votes
1 answer
52 views

Javascript: Array being passed as parameter doesn't retain values

I am trying to solve the problem Subsets using Javascript. The task is to print the powerset i.e., all subsets from an array. In the function below, I am passing an array as a parameter to collect all ...
argcv's user avatar
  • 51
0 votes
2 answers
89 views

Finding best result matching sets of items. Powerset optimization

I'm having this combination problem where I'm trying to find subsets of matching combinations of 2 items which results in the highest amount of total matches. Every item can only be in a match once. ...
Oehoe's user avatar
  • 61
1 vote
1 answer
104 views

More efficient powerset algorithm haskell

I Have a powerset function which creates a list [[a]] but the largest [a] is worked out first, meaning the whole algorithm has to run before I can get the smaller values. I need a function which ...
ineedhelp's user avatar
-1 votes
2 answers
59 views

Obtaining power set in mathematical order

The powerset of {1, 2, 3} is: {{}, {1}, {2}, {3}, {1, 2}, {1, 3}, {2, 3}, {1, 2, 3}} I have a String array in java, String elements={"apple","mango","banana"}; ...
Prashant Singh's user avatar
0 votes
1 answer
43 views

How to make a powerset in ascending order for the first item in a list?

I am trying to make a powerset of a list for the first item of that list in ascending order. However, I couldn't find on StackOverflow how to tackle this specific problem. When making a powerset of ...
Mathijsvdk's user avatar
2 votes
1 answer
183 views

Time complexity of Powerset in Python

The time complexity of this code to create a powerset from distinct integers is listed as O(n * 2^n) at all places including the Leetcode solution. I listed the complexity of each step as a code ...
bucksbros's user avatar
0 votes
2 answers
375 views

generating powerset with backtracking where subsets with lower number of elements appear earlier and they are sorted

I was solving the classic powerset generation using backtracking. Now, let's say, I add another constraint, the output should appear in a specific order. For input = [1, 2, 3], the output should be [[]...
Zabir Al Nazi's user avatar
0 votes
1 answer
58 views

How to generate powersets with a maximum size in C#?

I am trying to generate all powersets from a given list within a limit of given maximum size. I've found some great answers for how to generate powersets in general and admire the solution using ...
Elphie's user avatar
  • 3
0 votes
0 answers
68 views

How to modify this power set function to only include 'valid' subsets?

I am using a binomial tree as a list with 2^T - 1 'nodes' and want to create a set of subsets that work within some given criteria (outlined below) on the elements of the list. Right now, I use the ...
jodawg's user avatar
  • 1
1 vote
2 answers
403 views

Power set using BST in haskell

I have implemented a Set datatype in Haskell using Binary search tree. I have not used any of the in-built functions nor imported any module. My set datatype is as follows: data Set a = Empty | Node a ...
user avatar
1 vote
1 answer
603 views

Time Complexity of recursive Power Set function

I am having trouble with simplifying the time complexity for this recursive algorithm for finding the Power-Set of a given Input Set. I not entirely sure if what I have got is correct so far either. ...
tintins7a6164's user avatar

15 30 50 per page
1
2 3 4 5
15