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
Will the answer to this expression be POSITIVE or NEGATIVE?<br><br> - 100 - (- 98)
mina [271]

Answer:

-100-(-98)=-100+98=-2 then negative

3 0
3 years ago
Read 2 more answers
Sampson solves the inequality as shown below.
astraxan [27]

Answer:

subtract 3 from both sides

Step-by-step explanation:

7 0
3 years ago
If 8 is added to twice a number and this sum is multiplied by 3ˏ the result is the number multiplied by 3 and 9 is added to the
9966 [12]
n-a\ number\\\\(8+2n)\cdot3=3n+9\\\\8\cdot3+2n\cdot3=3n+9\\\\24+6n=3n+9\ \ \ \ /-24\\\\24-24+6n=3n+9-24\\\\6n=3n-15\ \ \ \ /-3n\\\\6n-3n=3n-3n-15\\\\3n=-15\ \ \ \ /:3\\\\3n:3=-15:3\\\\n=-5
8 0
3 years ago
What is 3/5 + 1/3 I got my Awncer but it says it's wrong ​
Harlamova29_29 [7]

Answer:

E 14/15

Step-by-step explanation:

3/5 = 9/15

1/3 = 5/15

8 0
3 years ago
Read 2 more answers
I have no idea how to do this, so if someone could at least do one of these I’ll be grateful &lt;3
jenyasd209 [6]

Answer:

Answers are below!

Step-by-step explanation:

(2 + g) (8)

= (2 + g) (8)

Add a 8 after the 2, and flip.

= (2)(8) + (g)(8)

= 16 + 8g

= 8g + 16

= (4) (8 + -5g)

Add another 4, then flip.

= (4) (8) + (4) (-5g)

= 32 − 20g

= - 20g + 32

−7 (5-n)

= (−7) (5 + -n)

Add another 7, then flip.

= (−7) (5) + (-7) (-n)

= −35 + 7n

= 7n - 35

Use the distributive property.

a (b + c) = ab + ac

a = 8

b = 2m

c = 1

= 8 × 2m + 8 × 1

Simplify, you get 16m + 8.

Use the distributive property.

a (b + c) = ab + ac

a = 6x

b = y

c = z

= 6xy - 6xz is the answer.

\mathrm{Apply\:the\:distributive\:law}:\quad \\\:a\left(b+c\right)=ab+ac

a=-3,\:b=2b,\:c=2a

=-3\cdot \:2b+\left(-3\right)\cdot \:2a

Apply minus plus rules.

=-3\cdot \:2b+\left(-3\right)\cdot \:2a

Multiply the numbers.

3 x 2 = 6

7 0
3 years ago
Read 2 more answers
Other questions:
  • Which website's purpose is the most credible?
    8·1 answer
  • The quotient 600÷2/3 tells about how far a tortoise may move in one hour. find that distance
    10·2 answers
  • Two buildings are 35 feet apart. The angle of elevation from the top of the smaller building to the top of the taller building i
    14·1 answer
  • Chase is deciding between two parking garages. Garage A charges an initial fee of $8
    8·1 answer
  • Alex is 4 years younger than 2 times his sister's age. Write a rule that represents Alex's age x as a function of his sister's a
    13·2 answers
  • Which of these choices are square roots of 144? Check all that apply. ​
    14·1 answer
  • Solve for x<br> -56 =8(x - 8)<br> x=
    14·2 answers
  • MULTIPLE CHOICE SHOW YOUR WORK. A bag contains 3 red, 5 yellow, and 7 purple marbles. What is the probability of drawing a purpl
    11·1 answer
  • You are a contractor who is installing a new kitchen floor with square tiles. The dimensions of the rectangular kitchen floor ar
    11·1 answer
  • The quantities xxx and yyy are proportional. xxx yyy 777 353535 121212 606060 202020 100100100 Find the constant of proportional
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!