

The heap sort algorithm always sort the data stored in arrays !!!




Examples:


Examples:


public class Heap { public double a[]; // Each array element a[i] represents a node // Like I said, I store a double in a node // So I define an array of double... public int NNodes; // This is the number of nodes in the heap ... methods still need to be written ... } 

Here is is code of the constructor added to the class:
public class Heap { public double a[]; // Each array element a[i] represents a node // Like I said, I store a double in a node // So I define an array of double... public int NNodes; // This is the number of nodes in the heap /* ===================================================================== Constructor: construct a heap that can contain "size" number of nodes ===================================================================== */ public Heap( int size ) { a = new double[ size + 1 ]; // Because a[0] is not used.... NNodes = 0; // There are 0 nodes in the heap right now... } ... Other methods still need to be written ... } 