Implements heap data type.
h- an array in which the data is stored
heapSize- the size of the heap
Heap- constructor for the Heap class, acepts numeric arrays as an input.
heapSort- method for performing sorting, runtime O(nlogn),although, very, very slow... not to be used for sorting arrays!!!
heapMaximum- returns maximum in the heap heapExtractMax- extracts maximum value from the heap
heapIncreaseKey- increses the key in the postion i
maxKeyInsert- inserts a key in the heap
made by Hanan Kavitz
free for distribution
The description should mention that this heap only sorts keys and does not support key-value pairs.
Heap is a very usefull data type used in many algorithms primarily due to the fact that you can get maximum number in the heap with runtime of O(1) and extracting maximum(or minimum) with runtime of O(logn).
What I meant is that sorting is done, in this case, much slower than just using sort(A).
For any other operation with Heap this code is good.
What is the point of this submission, if, as you say in your preamble to Heap, "very, very slow... not to be used for sorting arrays!!! "
Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.