public void ShuffleInPlace_ShufflesElements() { var rnd = new Random(1); int[] arr = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; int[] expected = { 7, 9, 5, 2, 10, 8, 6, 4, 1, 3 }; FisherYatesShuffle.ShuffleInPlace(arr, rnd); Assert.Equal(expected, arr); }
public void Test() { int max = 100; int k = 7; int[] nums = Enumerable.Range(0, max + 1).ToArray(); FisherYatesShuffle.ShuffleInPlace(nums); int hi = KthHighestNumber.Calc(nums, k); Assert.Equal(max - k + 1, hi); }