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
What is the surface area of a cylinder that is 5 centimeters high and has a diameter of 1.5 centimeters?
olchik [2.2K]

The surface area of cylinder is 8.625\pi cm^{2}, if the cylinder has 5 centimeters high and 1.5 cm of diameter.

Step-by-step explanation:

The given is,

          Cylinder has a 5 centimeters height

          Diameter of the cylinder is 1.5 centimeters

Step:1

          Formula for the surface area of cylinder is,

                     A=2\pi r h + 2\pi  r^{2}......................................(1)

          Where,

                   h - Height of cylinder

                   r - Radius of cylinder

        From the values of h and r,

                   r=\frac{d}{2}

                      = \frac{1.5}{2}

                   r  = 0.75 cm

       From the formula,

                      = ( 2 × \pi × 0.75 × 5 ) + ( 2 × \pi × 0.75^{2} )

                      = ( 7.5 \pi ) + ( 1.125 \pi )

                  A = 8.625\pi cm^{2}

Result:

        The surface area of cylinder is 8.625\pi cm^{2}, if the cylinder has 5 centimeters high and 1.5 cm of diameter.

3 0
3 years ago
If Gary is 11 years old how old are each of the family members
Korolek [52]

Answer:

everyone except his smaller siblings will be older than him

Step-by-step explanation:

if you need the correct answer say the full question you

                     dumb

3 0
3 years ago
How much higher is 500 than -400 m
gogolik [260]

Answer:

900m

Step-by-step explanation:

All you have to do is find the difference between the two measurements

500 - (-400)

Then, two negatives create a positive:

500 + 400

= 900

3 0
3 years ago
Read 2 more answers
If two sides of a triangle are 9cm and 15cm in length, which COULD be the measure of the third side?
MArishka [77]
The lemght could be 15 because a triangle has two long sides and one short one and the two are equivalent
5 0
3 years ago
The curve given by x=sin(t),y=sin(t+sin(t)) has two tangent lines at the point (x,y)=(0,0). List both of them in order of increa
SOVA2 [1]

Answer:

y = 0

y =2x

Step-by-step explanation:

Given parametric equations:

x (t) = sin (t)

y (t) = sin (t + sin (t))

The slope of the curve at any given point is given by dy / dx we will use chain rule to find dy / dx

(dy / dx) * (dx / dt) = (dy / dt)

(dy / dx) = (dy / dt) / (dx / dt)

Evaluate dx / dt and dy / dt

dx / dt = cos (t)

dy / dt = cos (t + sin (t)) * (1+cos (t))

Hence,

dy / dx = (1+cos(t))*cos(t + sin (t))) / cos (t)

@Given point (x,y) = 0 we evaluate t

0 = sin (t)

t = 0 , pi

Input two values of t and compute dy / dx

@ t = 0

dy / dx = (1 + cos (0))*cos (0 + sin (0))) / cos (0)

dy / dx = (1+1)*(1) / (1) = 2 @ t = 0

@t = pi

dy / dx = ( 1 + cos (pi))* cos (pi + sin (pi)) / cos (pi)

dy / dx = (1-1) * (-1) / (-1) = 0 @ t = pi

The corresponding gradients are 0 and 2 in increasing order and their respective equations are:

y = 2x

y = 0

5 0
3 years ago
Other questions:
  • 9/4 x = 8 1/2 what is x
    7·1 answer
  • mr.shu wants to hire one one of the two carpet companies to install carpeting in his basement. Is he more likely to hire Country
    6·1 answer
  • Which best describes this quadrilateral?
    9·1 answer
  • Two cylinders, a and b, each started with different amounts of water. The graph shows how the height of the water changed as the
    14·2 answers
  • Come to discord<br> just for talking
    5·1 answer
  • A plane flies at a steady rate of 40 mph while a second plane flies at a steady rate of 100 mph. The planes are 200 miles apart
    14·1 answer
  • 3 subtracted from 9 times 2 and 5 is added​
    12·2 answers
  • Which of the following is equivalent to<br> (5) 7/3?
    6·2 answers
  • The factorisation of 10xᴧ2 – 18xᴧ3 + 14xᴧ4 is
    8·1 answer
  • The mean weight of NINE players on a Basketball team is 177 POUNDS. Find the total weight of the nine players.
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!