forked from shreshthkhilani/Maps
-
Notifications
You must be signed in to change notification settings - Fork 0
/
BinaryMinHeapI.java
37 lines (32 loc) · 989 Bytes
/
BinaryMinHeapI.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
/**
* Defines an interface for a binary min heap
*/
public interface BinaryMinHeapI<K extends Comparable<? super K>>{
public boolean isEmpty();
/**
* Returns the least element in the heap
* @throws NoSuchElementException
* - if the heap is empty
*/
public K removeMin();
/**
* Adds the element to the heap
* @throws NullPointerException
* - if element is null
*/
public void insert(K element);
/**
* This function should update the value of the key
* oldElem to the value of newElem
*
* @param oldElem
* - current version of the element in the heap
* @param newElem
* - new version of the element to be added to the heap
* @throws NoSuchElementException
* - if oldElem is not in the heap
* @throws NullPointerException
* - if oldElem or newElem are null
*/
public void updateKey(K oldElem, K newElem);
}