Closed leahsidoniesmith closed 3 years ago
Please refer to https://emory.gitbook.io/dsa-java/priority-queues/unit-testing
@Test
public void testRobustness() {
List<Integer> keys = List.of(4, 1, 3, 2, 5, 6, 8, 3, 4, 7, 5, 9, 7);
Comparator<Integer> natural = Comparator.naturalOrder();
Comparator<Integer> reverse = Comparator.reverseOrder();
testRobustness(new LazyPriorityQueue<>(), keys, reverse);
testRobustness(new EagerPriorityQueue<>(), keys, reverse);
testRobustness(new BinaryHeap<>(), keys, reverse);
testRobustness(new LazyPriorityQueue<>(reverse), keys, natural);
testRobustness(new EagerPriorityQueue<>(reverse), keys, natural);
testRobustness(new BinaryHeap<>(reverse), keys, natural);
}
How do we initialize a binaryheap with the reverse order comparator so that we can create a min heap rather than a max heap?