Consider the following strategy for percolateDown. We have a hole at node X. Thenormal

Chapter 7, Problem 7.56

(choose chapter or problem)

Consider the following strategy for percolateDown. We have a hole at node X. Thenormal routine is to compare Xs children and then move the child up to X if it islarger (in the case of a (max)heap) than the element we are trying to place, therebypushing the hole down; we stop when it is safe to place the new element in thehole. The alternative strategy is to move elements up and the hole down as far aspossible, without testing whether the new cell can be inserted. This would place he new cell in a leaf and probably violate the heap order; to fix the heap order,percolate the new cell up in the normal manner. Write a routine to include thisidea, and compare the running time with a standard implementation of heapsort.

Unfortunately, we don't have that question answered yet. But you can get it answered in just 5 hours by Logging in or Becoming a subscriber.

Becoming a subscriber
Or look for another answer

×

Login

Login or Sign up for access to all of our study tools and educational content!

Forgot password?
Register Now

×

Register

Sign up for access to all content on our site!

Or login if you already have an account

×

Reset password

If you have an active account we’ll send you an e-mail for password recovery

Or login if you have your password back