Question: 1 . Let index = length / 2 - 1 . This is the parent of the last node in the tree, i . e
Let index length This is the parent of the last node in the tree, ie listindex listlength are leaves
Convert the subtree with root of listindex into a heap.
aGiven lista is root of tree, listb is left child root listc is right child root if exists
bCompare listb with listc to determine larger child, listlargerIndex
cCompare lista with listlargerIndex If lista listlargerIndex then swap, else already a heap
dIf swap, repeat step for the subtree of listlargerIndex
Convert the subtree with the root of listindex into a heap, repeat until list
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
