Skip to content

Instantly share code, notes, and snippets.

@mitchfriedman
Created February 17, 2015 23:17
Show Gist options
  • Save mitchfriedman/8efe6d09c077d1e8c619 to your computer and use it in GitHub Desktop.
Save mitchfriedman/8efe6d09c077d1e8c619 to your computer and use it in GitHub Desktop.
int parent = floor(position/2);
if(position != 0) {
/* less than 1, swap required */
if( (*queue)->compare( (*queue)->items[parent]->value, (*queue)->items[position]->value ) > 0 ) {
swap(queue, parent, position);
upHeap(queue, parent);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment