### Question:
WeightedBinaryTree { public static int getMinimumTreeWeight(int[] array) { if ((array == null) || (array.length == 0)) { throw new IllegalArgumentException("Input array is null or empty"); } int level = 0; int weight = 0; Arrays.sort(array); for (int i = 0; i < array.length; i++) { if (((i + 1) & i) == 0) { level++; } weight += level * array[array.length - 1 - i]; } return weight; }  static int getMinimumTreeWeight(int[] array);  }### Answer:
@Test(expected = IllegalArgumentException.class) public void testWeightedBinaryTreeNullArray() { getMinimumTreeWeight(null); }
@Test(expected = IllegalArgumentException.class) public void testWeightedBinaryTreeEmptyArray() { getMinimumTreeWeight(new int[0]); }
@Test public void testWeightedBinaryTree1() { assertThat(getMinimumTreeWeight(new int[] { 5 }), is(5)); }
@Test public void testWeightedBinaryTree2() { assertThat(getMinimumTreeWeight(new int[] { 5, 3 }), is(11)); }
@Test public void testWeightedBinaryTree3() { assertThat(getMinimumTreeWeight(new int[] { 4, 5, 3 }), is(19)); }
@Test public void testWeightedBinaryTree4() { assertThat(getMinimumTreeWeight(new int[] { 4, 5, 3, 4 }), is(30)); }
@Test public void testWeightedBinaryTree5() { assertThat(getMinimumTreeWeight(new int[] { 4, 5, 3, 7, 4 }), is(46)); }
@Test public void testWeightedBinaryTree6() { assertThat( getMinimumTreeWeight(new int[] { 4, 5, 100, 3, 7, 4, 5, 7 }), is(194)); }
@Test public void testWeightedBinaryTree7() { assertThat(getMinimumTreeWeight(new int[] { 1, 1, 1, 1, 1, 1, 1, 1 }), is(21)); }