Question
You are given n sorted lists L1, L2,..., each of length m, and if your goal is to form a single sorted list that is
You are given n sorted lists L1, L2,..., each of length m, and if your goal is to form a single sorted list that is the union of the clements in all the lists. Consider the following iterative algorithm: starting with a null (empty) list, merge it with L1, then merge the resuling list with L2, and so on up to merging with Ln where at the ith step, the result from the previous I-1 steps is merged with Li. Note that the resulting list after each merge is sorted. (a) In the worst case, what is the total number of comparisons in terms of n and m? (b) What is the asymptotic running time (Big O) of this algorithm in terms of n, and m?
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started