1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Damm [24]
3 years ago
12

"3. When we have two sorted lists of numbers in non-descending order, and we need to merge them into one sorted list, we can sim

ply compare the first two elements of the lists, extract the smaller one and attach it to the end of the new list, and repeat until one of the two original lists become empty, then we attach the remaining numbers to the end of the new list and it's done. This takes linear time. Now, try to give an algorithm using O(n log k) time to merge k sorted lists (you can also assume that they contain numbers in non-descending order) into one sorted list, where n is the total number of elements in all the input lists. Use a heap for k-way merging."
Mathematics
1 answer:
iren [92.7K]3 years ago
5 0

Answer:

Since we extract n elements in total, the algorithm for the running time for K sorted list is O (n log k+ k) = O (n log k)

Step-by-step explanation:

To understand better how we arrived at the aforementioned algorithm, we take it step by step

a, Construct a min-heap of the minimum elements from each of "k" lists.

The creation of this min-heap will cost O (k) time.

b) Next we run delete Minimum and move the minimum element to the output array.

Each extraction takes O (log k) time.

c) Then insert into the heap the next element from the list from which the element was extracted.

Now, we note that  since we extract n elements in total, the running time is

O (n log k+ k) = O (n log k).

So we can conclude that :

Since we extract n elements in total, the algorithm for the running time for K sorted list is O (n log k+ k) = O (n log k)

You might be interested in
Each stew pot can hold 6 liters of stew if there are 5 stew pots how much stew could be made at one time
m_a_m_a [10]

Answer:

Step-by-step explanation:

5p(6L/p)=30L

30 liters can be made with the five pots.

3 0
3 years ago
Read 2 more answers
if Sandy can afford car payments of $140/month for 4 years what is the price of a car that she can afford now?
Galina-37 [17]
6720 would be the correct answer

5 0
2 years ago
Sue wrote a double facts.It has a sum less than 10 and greater than 4.The addends are each less than 5.What fact might she have
Eduardwww [97]
Maybe 2+3 is the answr

6 0
3 years ago
Before a race, Evelyn ran 27 minutes to warm up. The race took her 2 hours.
Gwar [14]

Answer:

C. 147 minutes

Step-by-step explanation:

This is 147 minutes because 2 hours equal up to 120 minutes, before that Evelyn ran 27 minutes. So, now you have to add 120 and 27. You get 147.

4 0
3 years ago
After a party, 5/8of a pizza was left .For dinner, Olivia ate 3/8 of the
goblinko [34]
1/4 of the pizza was left after dinner
3 0
1 year ago
Other questions:
  • Please help me with this! If you’re smart you can solve it!
    7·1 answer
  • Someone tell me how to solve and the answers?
    7·1 answer
  • Mrs.Conley can type 3 pages in one hour. How many hours will it take her to type a 123 page paper
    5·1 answer
  • Suppose someone tells you that she has a triangle with sides having lengths 2.6, 8.1, and 8.6. Is this a right triangle? Why or
    6·1 answer
  • -12 -4x + 3 = -1 what is the value of x
    10·2 answers
  • Simplify the given expression below:
    5·2 answers
  • Which is equivalent to 450b^9 after it has been simplified completely?
    10·1 answer
  • Which statement is true about the equation fraction 3 over 4z = fraction 1 over 4z − 3 + 5?
    13·2 answers
  • Explain how you know that 4/5 =8/10
    10·1 answer
  • What is the area of the logo?​
    12·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!