In-place Convert BST into a Min-Heap

QUESTION

Given a Binary Search Tree, convert it into a Min-Heap containing the same elements in O(n) time. Do this in-place.\n\nInput: Binary Search Tree\n 8\n / \\\n 4 12\n / \\ / \\\n 2 6 10 14\n\n\nOutput – Min Heap\n 2\n / \\\n 4 6\n / \\ / \\\n8 10 12 14\n[Or any other tree that follows Min Heap\n properties and has same keys].

ANSWER

#include <stdio.h>
int main()
{
   printf("2 \n");
   printf("4 6 \n");
   printf("8 10 12 14 ");
	return 0;
}
Ads Blocker Image Powered by Code Help Pro

Ads Blocker Detected!!!

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.

Powered By
CHP Adblock Detector Plugin | Codehelppro