Purchase Solution

Heapsort: Heapify

Not what you're looking for?

Ask Custom Question

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?

Purchase this Solution

Solution Summary

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

Purchase this Solution


Free BrainMass Quizzes
Basic Computer Terms

We use many basic terms like bit, pixel in our usual conversations about computers. Are we aware of what these mean? This little quiz is an attempt towards discovering that.

Word 2010: Table of Contents

Ever wondered where a Table of Contents in a Word document comes from? Maybe you need a refresher on the topic? This quiz will remind you of the keywords and options used when working with a T.O.C. in Word 2010.

Basic Networking Questions

This quiz consists of some basic networking questions.

Inserting and deleting in a linked list

This quiz tests your understanding of how to insert and delete elements in a linked list. Understanding of the use of linked lists, and the related performance aspects, is an important fundamental skill of computer science data structures.

Javscript Basics

Quiz on basics of javascript programming language.