Click or drag to resize

CombinatoricsGenerateVariation Method

Overload List
 NameDescription
Public methodStatic memberGenerateVariation(BigInteger, Int32, Random) Generate a random variation, without repetition, by randomly selecting k of n elements with order. This is an O(k) space-complexity implementation optimized for very large N.
The space complexity of Fisher-Yates Shuffling is O(n+k). When N is very large, the algorithm will be unexecutable in limited memory, and a more memory-efficient algorithm is needed.
You can explicitly cast N to BigInteger if N is out of range of Int32 or memory, so that this special implementation is called. However, this implementation is slower than Fisher-Yates Shuffling: don't call it if time is more critical than space.
The K of type BigInteger seems impossible, because the returned array is of size K and must all be stored in memory.
Public methodStatic memberGenerateVariation(Int32, Int32, Random) Generate a random variation, without repetition, by randomly selecting k of n elements with order. Implemented using partial Fisher-Yates Shuffling.
Top
See Also