Code covered by the BSD License  

Highlights from
Heap

Be the first to rate this file! 6 Downloads (last 30 days) File Size: 2.12 KB File ID: #34218

Heap

by

 

heap data type

| Watch this File

File Information
Description

Implements heap data type.

 properties:
      h- an array in which the data is stored
     heapSize- the size of the heap
 methods:
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

Required Products MATLAB
MATLAB release MATLAB 7.13 (R2011b)
Other requirements should work fine on any Matlab release starting from 2008
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (3)
07 May 2014 Yasha

The description should mention that this heap only sorts keys and does not support key-value pairs.

24 Dec 2011 Hanan Kavitz

Derec Hello,
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.

22 Dec 2011 Derek O'Connor

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!!! "

Contact us