Skip to content

Instantly share code, notes, and snippets.

@nerohoop
Created January 9, 2018 00:48
Show Gist options
  • Save nerohoop/895bd2eef32bb8385763d07a6c78734e to your computer and use it in GitHub Desktop.
Save nerohoop/895bd2eef32bb8385763d07a6c78734e to your computer and use it in GitHub Desktop.
1. Build a max heap from the input data.
2. Replace the root with the last item of the heap followed by reducing the size by 1.
3. Heapify the root of tree.
4. Repeat above steps while size of heap is greater than 1.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment