help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Finding all subsets


From: Bill Denney
Subject: RE: Finding all subsets
Date: Tue, 5 Jul 2005 10:33:43 -0400 (EDT)

Wow, I spent time doing my implementation much worse than that. It just goes to show that searching for functions is definitely worth it.

Bill

On Tue, 5 Jul 2005, Hall, Benjamin wrote:

Does nchoosek help?

v = 1:3;
for kk = 0:length(v)
  nchoosek( v, kk )
end

-----Original Message-----
From: Søren Hauberg [mailto:address@hidden
Sent: Tuesday, July 05, 2005 10:10 AM
To: Mike Miller
Cc: Help-Octave List
Subject: Re: Finding all subsets


Mike Miller wrote:
On Tue, 5 Jul 2005, Soren Hauberg wrote:

I can't seem to wrap my mind around a very simple problem.
I need to find all possible subsets of a set.
Example:
All possible subsets of
[1, 2, 3]
is
{ [1], [2], [3], [1, 2], [1, 3], [2, 3], [1, 2, 3] }


Is [] (null set) also a subset?
I guess it is, I simply forgot to list it.

An n-vector has 2^n subsets, if the null set is included.

I'm not sure what the best way is to extract the subsets and I don't
know how you want them organized in matrices or whatever.
The best way would be a cell array of vectors (octave represents sets as
vectors).


Mike
Thanks,
Søren



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------


--
"Maybe I shouldn't learn about life from a guy who counts with his toes."
"And thinks with his guts."
  -- Rex and Dogbert


reply via email to

[Prev in Thread] Current Thread [Next in Thread]