Merging K- Sorted Lists using Priority Queue

后端 未结 7 1551
无人及你
无人及你 2021-01-06 18:17

I have been asked in my algorithm class to make a K-way merge algorithm which is of O(nlogk) After searching i found it could be done via making a k length prio

相关标签:
7条回答
  • 2021-01-06 18:47

    1 list is exhausted when it has no more elements

    2 you need to keep track from which list did the min element com

    3 for each element you put it into a min heap of size k which takes logk so you have n times logk

    0 讨论(0)
提交回复
热议问题