Computer Science Homework Solutions
Problem
#104642

What is the effect of calling HEAPIFY(A, i) when the element A[i] is larger than its children?

Consider the following definition of HEAPIFY.

HEAPIFY(A, i)
1 l  = LEFT(i)
2 r  = RIGHT(i)
3 if l   <  heap-size[A] and A[l] > A[i]
4     then largest =  l
5     else largest =  i
6 if r  <  heap-size[A] and A[r] > A[largest]
7     then largest =  r
8 if largest  != i
9     then exchange A[i] and  A[largest]
10          HEAPIFY(A,largest)


What is the effect of calling HEAPIFY(A, i) when the element A[i] is larger than its children?


Solution Summary

It is a very brief answer, explaining the WHY of it as well.

Solution
What is this?
By OTA - Overall OTA Rating
Purchase Cost Now
$2.19 CAD (was ~$3.99)
Included in Download
  • Plain text response
$2.19 Instant Download
Add to Cart
Why you can trust BrainMass.com
  • Your Information is Secure
  • Best Online Academic Help Service
  • Students find real academic Success
Related Solutions
  • Data Structure C++ - Is it possible to search for an item in heap structure efficiently (i.e. better than n comparisons)? Explain.
  • Merging Sorted Lists using Heaps - I need help figuring out an algorithm that will merge k sorted lists into one sorted lists in O(n lg k) time where n is the number of elements in ALL the input lists. I believe we are supposed to u ...
  • C++ STL Heap - See attached file for full problem description. Answer question #17. - Heaps, Binary Files, and Bit Sets
  • Programming language - 1. Some programming languages are typeless. What are a few of the obvious advantages and disadvantages of having no types in a language. Keep your answer to 1 paragraph or less. 2. Dynamic type b ...
  • Writing a linear-time boolean function for a HEAP structure. - Write a linear-time Boolean function HEAP(T:BINARY_TREE) which returns TRUE is T is a heap, i.e., it is partially ordered. Assume that T is represented using pointers to left and right children. Prove ...
Browse