Ask your own question, for FREE!
Computer Science 7 Online
OpenStudy (anonymous):

Oscar gets the bright idea of adding an arbitrary removeElementAtIndex (int i) to his array-based heap implementation. His implementation does the following: it re- moves the i-th element and replaces it with the last element (the element at the lowest level all the way to the right). To x the heap so that the heap property is preserved, he then bubbles it down the heap, swapping it with any elements that are greater than it. Unfortunately, this solution will not work. Provide an example heap con guration and such a remove operation for which it would fail.

OpenStudy (anonymous):

Think about it; what are the characteristics of a heap? Why would a bubble sort fail to return the transposed last element to its original position?

OpenStudy (anonymous):

Got it. Thanks!

OpenStudy (anonymous):

I'm glad to help

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!