Let us construct the BST shown in the above figure
BinaryTree tree = new BinaryTree ( ) ; tree . root = new Node ( ' A ' ) ; tree . root . left = new Node ( ' B ' ) ; tree . root . right = new Node ( ' C ' ) ; tree . root . right . left = new Node ( ' E ' ) ; tree . root . right . right = new Node ( ' F ' ) ; tree . root . right . left . left = new Node ( ' G ' ) ; tree . root . right . left . left . left = new Node ( ' I ' ) ; tree . root . right . left . left . right = new Node ( ' J ' ) ; tree . root . right . right . right = new Node ( ' H ' ) ; tree . root . right . right . right . left = new Node ( ' H ' ) ; char k = ' H ' ; System . out . println ( " Distance ▁ of ▁ the ▁ closest ▁ key ▁ from ▁ " + k + " ▁ is ▁ " + tree . findClosest ( tree . root , k ) ) ; k = ' C ' ; System . out . println ( " Distance ▁ of ▁ the ▁ closest ▁ key ▁ from ▁ " + k + " ▁ is ▁ " + tree . findClosest ( tree . root , k ) ) ; k = ' E ' ; System . out . println ( " Distance ▁ of ▁ the ▁ closest ▁ key ▁ from ▁ " + k + " ▁ is ▁ " + tree . findClosest ( tree . root , k ) ) ; k = ' B ' ; System . out . println ( " Distance ▁ of ▁ the ▁ closest ▁ key ▁ from ▁ " + k + " ▁ is ▁ " + tree . findClosest ( tree . root , k ) ) ; } }