Let us construct the BST shown in the above figure
root = Node ( ' A ' ) NEW_LINE root . left = Node ( ' B ' ) NEW_LINE root . right = Node ( ' C ' ) ; NEW_LINE root . right . left = Node ( ' E ' ) ; NEW_LINE root . right . right = Node ( ' F ' ) ; NEW_LINE root . right . left . left = Node ( ' G ' ) ; NEW_LINE root . right . left . left . left = Node ( ' I ' ) ; NEW_LINE root . right . left . left . right = Node ( ' J ' ) ; NEW_LINE root . right . right . right = Node ( ' H ' ) ; NEW_LINE root . right . right . right . left = Node ( ' K ' ) ; NEW_LINE k = ' H ' ; NEW_LINE print " Distance ▁ of ▁ the ▁ closest ▁ key ▁ from ▁ " + k + " ▁ is " , NEW_LINE print findClosest ( root , k ) NEW_LINE k = ' C ' NEW_LINE print " Distance ▁ of ▁ the ▁ closest ▁ key ▁ from ▁ " + k + " ▁ is " , NEW_LINE print findClosest ( root , k ) NEW_LINE k = ' E ' NEW_LINE print " Distance ▁ of ▁ the ▁ closest ▁ key ▁ from ▁ " + k + " ▁ is " , NEW_LINE print findClosest ( root , k ) NEW_LINE k = ' B ' NEW_LINE print " Distance ▁ of ▁ the ▁ closest ▁ key ▁ from ▁ " + k + " ▁ is " , NEW_LINE print findClosest ( root , k ) NEW_LINE