Skip to content

Instantly share code, notes, and snippets.

@kartikkukreja
Last active August 29, 2015 14:04
Show Gist options
  • Save kartikkukreja/2f6ffbdf1277008b5f3b to your computer and use it in GitHub Desktop.
Save kartikkukreja/2f6ffbdf1277008b5f3b to your computer and use it in GitHub Desktop.
Multiway merge
Let H be a min heap of size m
add first element of each list to H
Let O be the output list
while !H.empty()
e = H.deleteMin()
add e to O
add to H the next element of the list e was taken from
return O
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment