### Question:
DutchFlagSorter { public static void sort(DutchFlag flag, int n) { int i = 0, j = n - 1; for (int k = 0; k <= j;) { if (flag.color(k) == 1) { k++; } else if (flag.color(k) == 0) { flag.swap(i++, k++); } else { flag.swap(k, j--); } } }  static void sort(DutchFlag flag, int n);  }### Answer:
@Test public void sort() { int n = 5; DutchFlag flag = new DutchFlag(5); System.out.println(flag); DutchFlagSorter.sort(flag, 5); System.out.println(flag); Assert.assertTrue(flag.isSort()); }
@Test(timeout = 200) public void testSort() { int N = 1000; for (int i = 0; i < N; i++) { for (int j = 0; j < 10; j++) { DutchFlag flag = new DutchFlag(i); DutchFlagSorter.sort(flag, i); Assert.assertTrue(flag.isSort()); } } }