Constructing tree given in the above figure
root = newNode ( 3 ) NEW_LINE root . left = newNode ( 2 ) NEW_LINE root . right = newNode ( 5 ) NEW_LINE root . left . left = newNode ( 1 ) NEW_LINE root . left . right = newNode ( 4 ) NEW_LINE print ( " Before ▁ Replacing ▁ Nodes " ) NEW_LINE printInorder ( root ) NEW_LINE replaceNode ( root ) NEW_LINE print ( ) NEW_LINE print ( " After ▁ Replacing ▁ Nodes " ) NEW_LINE printInorder ( root ) NEW_LINE