Merge K sorted List
思路:
Solution 1 : time O(nk*log(k)) space: O(k)
Similar to Graph traverse
Initial state, expand and generate rule and termination condition, (need de-duplicate)
Best First search ( priority queue)
Solution 2 :(binary reduction) O(nk*log(k)), space(nk)
similar to merge sort, binary merge 2 sorted
solution 3 : merger sort two by two, until only one last
for solution 2 and 3, time complexity is the same, however if the array sizes are big, and we need to have file read/write involved. Solution 1 only needs to read/write each element only once , but the solution 2 needs to read/write each element log(k) which is the bottle neck of the system.