Question: Problem 3 ( Develop Multiway Merge Algorithm, 1 5 points ) . We studied the problem of merging 2 sorted lists lst 1 and lst
Problem Develop Multiway Merge Algorithm, points
We studied the problem of merging sorted lists lst and lst into a single sorted list in time mn where m is the size of lst and n is the size of lst Let twoWayMergelst lst represent the python function that returns the merged result using the approach presented in class.
In this problem, we will explore algorithms for merging k different sorted lists, usually represented as a list of sorted lists into a single list.
A points
Suppose we have k lists that we will represent as lists lists listsk for convenience and the size of these lists are all assumed to be the same value n
We wish to solve multiway merge by merging two lists at a time:
mergedList lists # start with list for i k do mergedList twoWayMergemergedList listsi return mergedList
Knowing the running time of the twoWayMerge algorithm as mentioned above, what is the overall running time of the algorithm in terms of nk
Note that this part is not graded. You are encouraged to answer it for your own understanding.
YOUR ANSWER HERE
B Implement an algorithm that will implement the k way merge by calling twoWayMerge repeatedly as follows:
Call twoWayMerge on consecutive pairs of lists twoWayMergelists lists twoWayMergelistsk listskassume k is even
Thus, we create a new list of lists of size k
Repeat steps until we have a single list left.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
