MathGroup Archive 1995

[Date Index] [Thread Index] [Author Index]

Search the Archive

More on KSubsets

  • Subject: [mg2429] More on KSubsets
  • From: wself at (Will Self)
  • Date: Thu, 9 Nov 1995 04:41:42 GMT
  • Approved:
  • Distribution: local
  • Newsgroups: wri.mathgroup
  • Organization: Wolfram Research, Inc.
  • Sender: daemon at ( )

Axel's question about KSubsets has some interesting variations.
For example, there is another possibly useful order on the k-subsets,
different from the lexicographic one.  For a finite subset s of the non-negative integers, compute the number n such that the digits in the
binary representation for n corresponding to elements of s are 1, and the
rest of the digits are 0.  For the set {0,1,3} the associated number would
be 2^0 + 2^1 + 2^3 = 11.

Now you can order the subsets s according to their associated numbers n.
It's no problem to create the function nthSubset, which gives the nth
subset in this ordering, but what about the function nthKSubset, which
for a given k would return the nth k-subset in this ordering?  Anyone
have a nice way to do this?

Will Self

  • Prev by Date: Re: Novice user
  • Next by Date: Speed of Mathematica under Windows 95
  • Previous by thread: Re: Novice user
  • Next by thread: More on KSubsets