### Question:
FindNthMaxNumber { public static int findNthMaxNumberUsingSelectionSearch(int[] sequence, int n) { if (sequence == null) { throw new IllegalArgumentException("Input array is null"); } if (n < 1) { throw new IllegalArgumentException("Input n is non-positive"); } if (sequence.length < n) { throw new IllegalArgumentException("Array size is less than input n"); } return findNthMaxNumberUsingSelectionSearch(copyOf(sequence, sequence.length), n - 1, 0, sequence.length - 1); }  static int findNthMaxNumberUsingSelectionSearch(int[] sequence, int n); static int findNthMaxNumberUsingBinaryHeap(int[] sequence, int n);  }### Answer:
@Test(expected = IllegalArgumentException.class) public void testFindNthMaxNumberUsingSelectionSearchNullArray() { findNthMaxNumberUsingSelectionSearch(null, 1); }
@Test(expected = IllegalArgumentException.class) public void testFindNthMaxNumberUsingSelectionSearchLowN() { findNthMaxNumberUsingSelectionSearch(new int[]{2, 1, 3, 4, 0}, 0); }
@Test(expected = IllegalArgumentException.class) public void testFindNthMaxNumberUsingSelectionSearchHighN() { findNthMaxNumberUsingSelectionSearch(new int[]{2, 1, 3, 4, 0}, 6); }
@Test public void testFindNthMaxNumberUsingSelectionSearch1() { int[] sequence = new int[]{2, 1, 3, 4, 0, -1, 7, 5}; assertThat(findNthMaxNumberUsingSelectionSearch(sequence, 1), is(7)); assertThat(findNthMaxNumberUsingSelectionSearch(sequence, 2), is(5)); assertThat(findNthMaxNumberUsingSelectionSearch(sequence, 3), is(4)); assertThat(findNthMaxNumberUsingSelectionSearch(sequence, 4), is(3)); assertThat(findNthMaxNumberUsingSelectionSearch(sequence, 5), is(2)); assertThat(findNthMaxNumberUsingSelectionSearch(sequence, 6), is(1)); assertThat(findNthMaxNumberUsingSelectionSearch(sequence, 7), is(0)); assertThat(findNthMaxNumberUsingSelectionSearch(sequence, 8), is(-1)); }
@Test public void testFindNthMaxNumberUsingSelectionSearch2() { int[] sequence = new int[]{2, -4, 5, 6, 0, 7, -1, 10, 9}; assertThat(findNthMaxNumberUsingSelectionSearch(sequence, 1), is(10)); assertThat(findNthMaxNumberUsingSelectionSearch(sequence, 2), is(9)); assertThat(findNthMaxNumberUsingSelectionSearch(sequence, 3), is(7)); assertThat(findNthMaxNumberUsingSelectionSearch(sequence, 4), is(6)); assertThat(findNthMaxNumberUsingSelectionSearch(sequence, 5), is(5)); assertThat(findNthMaxNumberUsingSelectionSearch(sequence, 6), is(2)); assertThat(findNthMaxNumberUsingSelectionSearch(sequence, 7), is(0)); assertThat(findNthMaxNumberUsingSelectionSearch(sequence, 8), is(-1)); assertThat(findNthMaxNumberUsingSelectionSearch(sequence, 9), is(-4)); }