Given a Binary Search Tree of size N, your task is to complete the function changeKey() that change old key value present in the tree and changes it to new key value.
Input: Root of below tree 50 / \ 30 70 / \ / \ 20 40 60 80 Old key value: 40 New key value: 10 Output: BST should be modified to following 50 / \ 30 70 / / \ 20 60 80 / 10
The function takes three arguments, reference pointer to the root node of the BST, old key value of the node and a new key value.
There will be T test cases and for each test case the function will be called separately.
For each test case output the Inorder traversal of the Tree.
20 8 22 4 12 10 14
1 4 10 12 14 20 22
Note:The Input/Ouput format and Example given are used for system's internal purpose, and should be used by a user for Expected Output only. As it is a function problem, hence a user should not read any input from stdin/console. The task is to complete the function specified, and not to write the full code.
If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.