MCPcopy
hub / github.com/TheAlgorithms/Java / Heap

Interface Heap

src/main/java/com/thealgorithms/datastructures/heaps/Heap.java:21–44  ·  view source on GitHub ↗

Interface common to heap data structures. Heaps are tree-like data structures that allow storing elements in a specific way. Each node corresponds to an element and has one parent node (except for the root) and at most two children nodes. Every element contains a key, and those keys indicat

Source from the content-addressed store, hash-verified

19 * @author Nicolas Renard
20 */
21public interface Heap {
22 /**
23 * @return the top element in the heap, the one with lowest key for min-heap
24 * or with the highest key for max-heap
25 * @throws EmptyHeapException if heap is empty
26 */
27 HeapElement getElement() throws EmptyHeapException;
28
29 /**
30 * Inserts an element in the heap. Adds it to then end and toggle it until
31 * it finds its right position.
32 *
33 * @param element an instance of the HeapElement class.
34 */
35 void insertElement(HeapElement element);
36
37 /**
38 * Delete an element in the heap.
39 *
40 * @param elementIndex int containing the position in the heap of the
41 * element to be deleted.
42 */
43 void deleteElement(int elementIndex) throws EmptyHeapException;
44}

Callers 16

testInsertElementMethod · 0.65
testGetElementAtIndexMethod · 0.65
testDeleteElementMethod · 0.65
testExtractMinMethod · 0.65
testHeapOrderMethod · 0.65
testSizeAndEmptyMethod · 0.65
testInsertElementMethod · 0.65
testInsertElementMethod · 0.65
testInsertNullElementMethod · 0.65
testInsertElementMethod · 0.65
testInsertNullElementMethod · 0.65

Implementers 2

MaxHeapsrc/main/java/com/thealgorithms/datast
MinHeapsrc/main/java/com/thealgorithms/datast

Calls

no outgoing calls

Tested by

no test coverage detected