Problem

A crossover between Floyd’s and Williams’s methods for constructing a heap is a method in...

A crossover between Floyd’s and Williams’s methods for constructing a heap is a method in which an empty position occupied by an element is moved down to the bottom of the tree and then the element is moved up the tree, as in Williams’s method, from the position that was just moved down. A pseudocode of this function is as follows:

i = n/2-1; // position of the last parent in the array of n elements;while (i >= 0)  // Floyd’s phase:  tmp = data[i];  consider element data[i] empty and move it down to the bottom swapping it every time with larger child;  put tmp in the leaf at which this process ended;  // Williams’s phase:  while tmp is not the root data[i] of the current tree and it is larger than its parent   swap tmp with its parent;  i--; // go to the preceding parent;

It has been shown that this algorithm requires 1.65n comparisons in the average case (McDiarmid and Reed 1989). Show changes in the array [2 8 6 1 10 15 3 12 11] during execution of the algorithm. What is the worst case?

Step-by-Step Solution

Request Professional Solution

Request Solution!

We need at least 10 more requests to produce the solution.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the solution will be notified once they are available.
Add your Solution
Textbook Solutions and Answers Search
Solutions For Problems in Chapter 6
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT