Given a Binary Tree, convert it to Binary Search Tree in such a way that keeps the original structure of Binary Tree intact.
Output: 1 2 3
Output: 1 2 3 4
The converted BST will be 3
You don't need to read input or print anything. Your task is to complete the function binaryTreeToBST() which takes the root of the Binary tree as input and returns the root of the BST. The driver code will print inorder traversal of the converted BST.
Expected Time Complexity: O(NLogN). Expected Auxiliary Space: O(N).