Question

Suppose that you are performing a reheapification downward. Write a precise condition (not code) that describes the situation that causes the reheapification to stop.

Here is an array of ten integers:

5 3 8 9 1 7 0 2 6 4

What does this array look like after the FIRST iteration of the large loop in a selection sort (sorting from smallest to largest) ?

Draw a new heap that is created by removing one item (the root) from the following heap:

910 5 68 1 311

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Given Array is

4 8 2-7 5 4 9-3 8-2 3

For each pass, we will move left to right looking for the next largest value. Once that is found, it will be swapped into its final position (these will be shown in lighter color).

Starting pass 0

4-9 6-8 2-7 0-6 5 4 9-3 8-2 3-1

Initialize bigindex.

For each element moving through the list: the biggest seen so far is always red.

4-9 6-8 2-7 0-6 5 4 9-3 8-2 3

Compare to biggest seen so far.

4 2-7 6 5 4 9-3 3 3-1 0

Found something bigger, so switch value of bigindex.

4-9 6-8 2-7 0-6 5 4 9 3 3 3

Compare to biggest seen so far.Found something bigger, so switch value of bigindex.

4-9 6-8 2-7 0-6 5 4 9 3 8-2 3-1

Compare to biggest seen so far.

4-9 6-8 2-7 0-6 5 1.4 9 8-2 3 5 0

.

. so on

9 す 4 6-8 2-7 0-6 5 4 9 8-2 3 0

Now swap the next biggest element into place.

9 す 6-8 2-7 6 5 4-3

Given Max Heap is

910 5 68 1 311

First We move the Root Node as a Leaf Node

910 68

Delete the Node 910

68

Here 11<77 so move 77 in place of 11.

68

Here 11<68 so move 68 in place of 11.

68

Which is Required Heap afer Deleting Root

Add a comment
Know the answer?
Add Answer to:
Suppose that you are performing a reheapification downward. Write a precise condition (not code) that describes the situation that causes the reheapification to stop. Here is an array of ten integers:...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • //Generic interface that describes various searching and sorting //algorithms. Note that the type parameter is unbounded....

    //Generic interface that describes various searching and sorting //algorithms. Note that the type parameter is unbounded. However, //for these algorithms to work correctly, the data objects must //be compared using the method compareTo and equals. //In other words, the classes implementing the list objects //must implement the interface Comparable. The type parameter T //is unbounded because we would like to use these algorithms to //work on an array of objects as well as on objects of the classes //UnorderedArrayList and...

  • What is the role of polymorphism? Question options: Polymorphism allows a programmer to manipulate objects that...

    What is the role of polymorphism? Question options: Polymorphism allows a programmer to manipulate objects that share a set of tasks, even though the tasks are executed in different ways. Polymorphism allows a programmer to use a subclass object in place of a superclass object. Polymorphism allows a subclass to override a superclass method by providing a completely new implementation. Polymorphism allows a subclass to extend a superclass method by performing the superclass task plus some additional work. Assume that...

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
ADVERTISEMENT
ADVERTISEMENT