powerset Questions
16
Solved
I need to get all possible subsets of an array.
Say I have this:
[1, 2, 3]
How do I get this?
[], [1], [2], [3], [1, 2], [2, 3], [1, 3], [1, 2, 3]
I am interested in all subsets. For subsets of s...
Titanothere asked 13/3, 2017 at 21:35
16
Solved
Given a set {1,2,3,4,5...n} of n elements, we need to find all subsets of length k .
For example, if n = 4 and k = 2, the output would be {1, 2}, {1, 3}, {1, 4}, {2, 3}, {2, 4}, {3, 4}.
I am not...
28
Solved
The powerset of {1, 2, 3} is:
{{}, {2}, {3}, {2, 3}, {1, 2}, {1, 3}, {1, 2, 3}, {1}}
Let's say I have a Set in Java:
Set<Integer> mySet = new HashSet<Integer>();
mySet.add(1);
mySet....
32
Solved
Given a set
{0, 1, 2, 3}
How can I produce the subsets:
[set(),
{0},
{1},
{2},
{3},
{0, 1},
{0, 2},
{0, 3},
{1, 2},
{1, 3},
{2, 3},
{0, 1, 2},
{0, 1, 3},
{0, 2, 3},
{1, 2, ...
8
Solved
I have a List of elements (1, 2, 3), and I need to get the superset (powerset) of that list (without repeating elements). So basically I need to create a List of Lists that looks like:
{1}
{2}
{3}...
2
Solved
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 | Nod...
2
Solved
I need a t-sql code to get powerset of a resultset.
example input :
ColumnName
1
2
3
Example Output(one columns as nvarchar) :
1
2
3
1,2
1,3
2,3
1,2,3
Output set may contain duplicate values s...
Oviposit asked 26/4, 2016 at 8:26
8
Solved
I would like to efficiently generate a unique list of combinations of numbers based on a starting list of numbers.
example start list = [1,2,3,4,5] but the algorithm should work for [1,2,3...n]
...
8
Solved
I am studying for an interview and I stumbled upon this question online under the "Math" category.
Generate power set of given set:
int A[] = {1,2,3,4,5};
int N = 5;
int Total = 1 << N;
f...
5
I'm using the beginning language with list abbreviations for DrRacket and want to make a powerset recursively but cannot figure out how to do it. I currently have this much
(define
(powerset aL)
...
3
Solved
I am looking a function that return me all the unordered combination of a vector. eg
x <- c('red','blue','black')
uncomb(x)
[1]'red'
[2]'blue'
[3]'black'
[4]'red','blue'
[5]'blue','black'
[6]'r...
Isochronize asked 14/1, 2015 at 22:25
1
While trying to prove some things, I encountered an innocent looking claim that I failed to prove in Coq. The claim is that for a given Finite Ensemble, the powerset is also finite. The statement i...
Klecka asked 21/5, 2019 at 14:30
4
I couldn't find an answer to this anywhere, so here's my solution.
The question is: how can you calculate a power set in R?
It is possible to do this with the library "sets", with the command 2^a...
6
Solved
I'm trying to write python code to print the powerset of a string, but am running into some bugs. Here's what I've got:
def getperm (string):
perm = []
if len(string) == 0:
perm.append("")
ret...
3
Solved
I would like to have a function
powersetWithComplements :: [a] -> [([a], [a])]
Such that for example:
powersetWithComplements [1,2,3] = [([],[1,2,3]),([3],[1,2]),([2],[1,3]),([2,3],[1]),([1]...
Quote asked 11/12, 2017 at 14:37
8
Solved
I have a Set of items of some type and want to generate its power set.
I searched the web and couldn't find any Scala code that adresses this specific task.
This is what I came up with. It allows...
3
Solved
I am trying to build a list of subsets of a given set in Python with generators. Say I have
set([1, 2, 3])
as input, I should have
[set([1, 2, 3]), set([2, 3]), set([1, 3]), set([3]), s...
4
Solved
I have found numerous solutions across the web having O(2^n) complexity. Can someone help me figure out the time complexity of the code given below. Also it involves lot of bit manipulation and I a...
Chalet asked 20/12, 2013 at 20:20
3
I am trying to implement a function to generate the powerset of a list xs.
The general idea is that we walk through the elements of xs and choose whether to include x or not. The problem I'...
3
I am a complete beginner in Haskell and I have 11 exercises for homework, 10 of which I have already solved. I have found several solutions to get the powerset of a set, but none of them includes l...
Pickaxe asked 14/9, 2015 at 23:54
1
For the last few days, I've tried to accomplish the following task regarding the analysis of a Set of Objects, and the solutions I've come up with rely heavily on Memory (obtaining OutOfMemory exce...
Russianize asked 27/7, 2016 at 16:16
5
Solved
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 ph...
Apostil asked 10/9, 2011 at 11:3
5
Solved
Let's say we have a Set S which contains a few subsets:
- [a,b,c]
- [a,b]
- [c]
- [d,e,f]
- [d,f]
- [e]
Let's also say that S contains six unique elements: a, b, c, d, e and f.
How can we find ...
5
Solved
I have this code which generates power set of an array of size 4 (number is just example, less combinations to write...).
#define ARRAY_SIZE 4
unsigned int i, j, bits, i_max = 1U << ARRAY_...
Howlett asked 10/10, 2013 at 15:8
5
Solved
Given the input array
[a,b,c,d,e]
and a 'join' function (a,b) => (a+b)
my code returns the following array of arrays, containing each possible variation obtained by applying the join functio...
Ackler asked 16/4, 2013 at 11:28
1 Next >
© 2022 - 2024 — McMap. All rights reserved.