Convert a BST to max heap without using extra memory and in as optimum time as possible
-----------------------------------------------------------------
/* Bottom Up recursive code.
* Basic Idea: Swap the right child to its parent bottom up to make it a Max Heap.
*/
NODE* BSTMaxHeapify(NODE* Tree)
{
if(Tree==NULL)
return Tree;
BSTMaxHeapify(Tree->left);
BSTMaxHeapify(Tree->right);
return(BSTMaxHeapSwap(Tree,Tree->right));
}
NODE* BSTMaxHeapSwap(NODE* Root, NODE* RootRight)
{
if(RootRight==NULL)
return Root;
else
Swap the Root and RootRight Node;
return RootRight;
}
Plz comment if I have made any mistake