@Test(timeout = 3000) public void testShuffle() { Random r = new Random(); for (int n = 2; n <= 20; n ++) { System.out.println("test "+n); int N = 100000; int[][] check = new int[n][n]; for (int i = 0; i < N; i++) { Node cur = linkedList.buildLinkedList(n); linkedList.shuffle(cur); int[] res = new int[n]; for (int j = 0; j < n; j++, cur = cur.next) { res[cur.val]++; check[j][cur.val]++; } int[] expect = new int[n]; Arrays.fill(expect, 1); Assert.assertArrayEquals(expect, res); } double expect = N / n; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { Assert.assertTrue(Math.abs(expect - check[i][j]) <= 0.06 * expect); } } } }
public Node shuffle(Node list) { return null; }
ShuffleLinkedList { public Node shuffle(Node list) { return null; } }
ShuffleLinkedList { public Node shuffle(Node list) { return null; }  }
ShuffleLinkedList { public Node shuffle(Node list) { return null; }  Node buildLinkedList(int n); Node shuffle(Node list); }
ShuffleLinkedList { public Node shuffle(Node list) { return null; }  Node buildLinkedList(int n); Node shuffle(Node list);  }