-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMedianHeap.java
46 lines (37 loc) · 985 Bytes
/
MedianHeap.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
public interface MedianHeap<Key extends Comparable<Key>> {
/**
* Insert a new element in the Heap
*
* @param v Key to be inserted in the Heap
*/
public void insert(Key v);
/**
* Delete and return the median element in the Heap
* If there is two medians, it will return the maximum value of the two medians
* and delete all the two medians from the heap
*
* @return the median in the Heap
*
* @throws java.util.NoSuchElementException if the Heap is empty
*/
public Key delMedian();
/**
* Check if the Heap is empty
*
* @return true is the Heap is empty and false if not
*/
public boolean isEmpty();
/**
* Return the median element in the Heap
* If there is two medians, it will return the average of the two medians
*
* @return the median Key in the Heap
*
* @throws java.util.NoSuchElementException if the Heap is empty
*/
public Key median();
/**
* @return the size of the Heap
*/
public int size();
}