public void TestInsert() { var list = new List<int> { 1, 9, 3, 6, 5, 2, 7, 11, 9 }; var maxHeap = new MaxHeap(); list.ForEach(elem => maxHeap.Add(elem)); Assert.AreEqual(11, maxHeap.peekMax()); }
public void testBunchOfInsertionsAndDeletions() { var list = new List<double> { 74, 101, 11, 1000, 4, -101, -1000 }; var maxHeap = new MaxHeap(); list.ForEach(elem => maxHeap.Add(elem)); list.Sort(); list.Reverse(); var maxes = new List<double>(); for (int i = 0; i < list.Count; i++) { maxes.Add(maxHeap.removeMax()); } List<Tuple<double, double>> expectedVsActual = list.Zip(maxes, Tuple.Create).ToList(); foreach(var tuple in expectedVsActual) { Assert.AreEqual(tuple.Item1, tuple.Item2); } }
public MedianFinder() { upperPortion = new MinHeap(); lowerPortion = new MaxHeap(); }
public void testRemoveMaxWhenEmpty() { var minHeap = new MaxHeap(); minHeap.removeMax(); }