So the problem is to merge k sorted lists (assume they are sorted into ascending order) into 1 list of n elements using a min heap. Now i found a solution for it but am unsure if it could have a running time of nlogk. Here is my pseudo code, What do you guys think?

```
Algorithm kWayMerge(S)
  t ← 0
  Result ← ∅
  while t ≤ n do
      choosenHeap ← min(S1[1], … Sk[1])
      t ← t + 1
      Result[t] ← DeleteMin(choosenHeap)
  end loop
end

Function DeleteMin(H)
  Min ← A[1]
  A[1] ← A[size[H]]
  size[H] ← size[H] - 1
  DownHeap(H, 1)
  return Min
end

Function DownHeap(A, t)
  c ← 2*t
  if c > size[A] then
      return
  if c+1 > size[A] && A[c] > A[c + 1] then
      c ← c + 1
  temp ← A[t]
  A[t] ← A[c]
  A[c] ← temp
  DownHeap(A, c)
end

```

Basically my solution is to search the k lists and find the Min Heap with the smallest root value and put it into the resulting array. Basically the outer loop in kWayMerge will iterate n times due to removing all elements from the k sorted lists given.