Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@bmyerz
Created November 30, 2017 14:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bmyerz/0fba250de87cb33b5b2c16868107014a to your computer and use it in GitHub Desktop.
Save bmyerz/0fba250de87cb33b5b2c16868107014a to your computer and use it in GitHub Desktop.
void sort(int[] number)
{
PriorityQueue<Integer, Integer> p = new HeapPriorityQueue();
// insert array data into p
for (int i=0; i< number.length; 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