Question: ) Suppose you are given k sorted non - empty lists A 1 , dots, A k that consist of n elements in total. Your

) Suppose you are given k sorted non-empty lists A1,dots,Ak
that consist of n elements in total. Your task is to merge them into one
big sorted list. We will use the merge procedure described in class, which
can merge two lists into one in linear time, i.e., in (n1+n2) time where
n1 and n2 are the sizes of the two input lists, respectively. You may
assume that k is a power of 2.
(a)(5 points) Consider the following simple iterative algorithm: First
merge A1 and A2 into one list, then merge the resulting list with A3,
then A4,dots,Ak. Show that the (worst-case) running time of this
algorithm is O(nk).
(b)(2 points) Show that the O(nk) running time is tight, i.e., its running
time is also (nk), thus (nk).
(c)(2 points) What's the best-case running time of this iterative algo-
rithm? Explain.
 ) Suppose you are given k sorted non-empty lists A1,dots,Ak that

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!