First, an in-order traversal of the binary tree is performed to extract all node values in a sorted manner since in-order traversal of a BST inherently results in a sorted sequence.
Array to BST Construction:
Using the sorted node values from the in-order traversal, a balanced BST is constructed. This is achieved by recursively selecting the middle element of the current sub-array to ensure balanced height, setting it as the root, and applying the same process to the left and right halves to construct the subtrees.