Skip to content

Instantly share code, notes, and snippets.

@ro31337
Created June 28, 2016 23:36
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 ro31337/bedeb9b3edffa96b2338328e82426454 to your computer and use it in GitHub Desktop.
Save ro31337/bedeb9b3edffa96b2338328e82426454 to your computer and use it in GitHub Desktop.
public void add(int value)
{
list.Add(value);
int i = heapSize - 1;
int parent = (i - 1) / 2;
while (i > 0 && list[parent] < list[i])
{
int temp = list[i];
list[i] = list[parent];
list[parent] = temp;
i = parent;
parent = (i - 1) / 2;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment