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
Write 230.251 in expanded form
Tamiku [17]
200+30+0.2+0.05+0.001=230.251
5 0
3 years ago
Read 2 more answers
If you know the 7x8=56 how can you use the Commutative Property of Multiplication to find the product of 8x7?
boyakko [2]

Answer:

The communicative property for multiplication states that the order of the multiplicands and can be swapped and the resulting product stays the same.

So

A * B = B * A

So if

7*8=56

then the commutative property says

8*7=56 as well since you can swap the order of the terms on the left and not change the result.

This property is true for addition and multiplication. It does not hold for subtraction or division.

Hope that makes sense and helps. (:

5 0
3 years ago
If I did 2 tests a month for four months how many would I get done a month how many would I get done in four months.
AfilCa [17]

Answer: 2 per month

8 per four months

Step-by-step explanation:

6 0
3 years ago
Read 2 more answers
Jessa bought 15 pieces of ribbon. Each piece of ribbon was 2.25 yards long. What is the total amount of ribbon Jessa bought? ent
algol [13]
Hello,

15 pieces of ribbon, each is 2.25 yards long.
15 x 2.25 = 33.75 yards of ribbon.

Hope this helped!

3 0
3 years ago
Read 2 more answers
Hello, can someone plz make sure I’m correct. The photo is above !
maria [59]

it looks correct to me

ps. i hate savvas realize

4 0
2 years ago
Other questions:
  • 30 POINTS FOR WHOEVER CAN SOLVE THIS!!
    13·1 answer
  • Which expdession is equivalent to 4-2(3x-5)​
    12·1 answer
  • 64^2/3=<br> a)2<br> b)16<br> c)512
    9·2 answers
  • What is the best description of the data in the histogram?
    11·2 answers
  • The graph of f(t) = 6.2" shows the value of a rare coin in year t. What is the
    10·1 answer
  • A line passing through the point (12, -5) has a slope of 1/3
    15·1 answer
  • Please help meeeeee
    15·1 answer
  • What is the area of the trapezoid? [A = 5(61 + b2)h]
    13·1 answer
  • I could use some help answering this math problem!!
    14·1 answer
  • What is the volume of this object?<br> Top View<br> 2u<br> 2u<br><br><br><br> pls I need help lol
    12·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!