Knuth Class |
The Knuth class provides a client for reading in a sequence of strings and Shuffling them using the Knuth (or Fisher-Yates) shuffling algorithm. This algorithm guarantees to rearrange the elements in uniformly random order, under the assumption that Math.random() generates independent and uniformly distributed numbers between 0 and 1.
See for versions that shuffle arrays and subarrays of objects, doubles, and ints.
Namespace: Algs4Net
public class Knuth
The Knuth type exposes the following members.
Name | Description | |
---|---|---|
![]() ![]() | MainTest |
Reads in a sequence of strings from standard input, shuffles
them, and prints out the results. |
![]() ![]() | Shuffle |
Rearranges an array of objects in uniformly random order
(under the assumption that Math.random() generates independent
and uniformly distributed numbers between 0 and 1). |
For additional documentation, see Section 1.1 of Algorithms, 4th Edition by Robert Sedgewick and Kevin Wayne.
This class is a C# port from the original Java class Knuth implementation by the respective authors.