Created
November 15, 2017 18:22
-
-
Save kunigami/5612c56998cb09a6cc14dbe49c099e4e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let deleteMin (heap: heap) = | |
match heap with | |
| Empty -> raise Empty_heap | |
| Heap(_, primaryHeap) -> | |
if PrimaryHeap.isEmpty primaryHeap then Empty | |
else | |
let (Heap (newMinElem, minPrimaryHeap)) = | |
PrimaryHeap.findMin primaryHeap | |
in let restPrimaryHeap = PrimaryHeap.deleteMin primaryHeap | |
in Heap (newMinElem, PrimaryHeap.merge minPrimaryHeap restPrimaryHeap) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment