Click or drag to resize
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.

Inheritance Hierarchy
SystemObject
  Algs4NetKnuth

Namespace: Algs4Net
Assembly: Algs4Net (in Algs4Net.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
public class Knuth

The Knuth type exposes the following members.

Methods
  NameDescription
Public methodStatic memberMainTest
Reads in a sequence of strings from standard input, shuffles them, and prints out the results.
Public methodStatic memberShuffle
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).
Top
Remarks

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.

See Also