Created
November 30, 2017 16:44
-
-
Save bmyerz/42034d01b90c14839e46f369e9f778f4 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
void sort(int[] number) | |
{ | |
PriorityQueue<Integer, Integer> p = new HeapPriorityQueue(); | |
// insert array data into p | |
for (int i=0; i< number.length; i++) { | |
int x = number[i]; | |
p.insert(x, x); | |
} | |
// take out in sorted order putting into the array | |
int i = 0; | |
while (!p.isEmpty()) | |
{ | |
number[i] = p.deleteMin(); | |
i++; | |
} | |
// x is number sorted | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment