Question: 3 . For the following Heap Sort algorithm, a ) What are the properties of a Max Heap? b ) For the array A [
For the following Heap Sort algorithm,
a What are the properties of a Max Heap?
b For the array An represented by a heap, what will the following functions return: PARENTi; LEFTi; RIGHTi
c What are the minimum and maximum number of elements in a heap of height h Why?
d Is an array that is in sorted decreasing order a minheap? Why?
e What is the effect of calling MAXHEAPIFYA i for i Aheapsize
g Write an algorithm to build a heap using MAXHEAPIFY.
h Illustrate the operation of HEAPSORT on the array A
MAXHEAPIFY A i
LEFTi
r RIGHTi
if l Aheapsize and A Ai
largest l
else largest i
if r Aheapsize and Ar Alargest
largest r
if largest i
exchange Ai with Alargest
MAXHEAPIFY A largest
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
