Suppose you have k sorted arrays, each with n elements, and you
want to combine them into a
single sorted array of nk elements.
2.1 Here is one algorithm: merge the first two arrays, then merge
with the third, then merge with the fourth etc. What is the
complexity of this algorithm in terms of k and n?
2.2 Design a O(nk log(k)) algorithm to solve this problem,
preferably using a divideand-conquer approach, and analyze its
asymptotic running time.
Hint: In order to achieve O(nk log(k)) complexity, first pair the
lists in k/2 groups of 2.
Suppose you have k sorted arrays, each with n elements, and you want to combine them into a single sorted array of nk el
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
Suppose you have k sorted arrays, each with n elements, and you want to combine them into a single sorted array of nk el
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!