Let us create Binary Tree shown in above example
root = new Node ( 1 ) ; root . left = new Node ( 12 ) ; root . right = new Node ( 13 ) ; root . right . left = new Node ( 14 ) ; root . right . right = new Node ( 15 ) ; root . right . left . left = new Node ( 21 ) ; root . right . left . right = new Node ( 22 ) ; root . right . right . left = new Node ( 23 ) ; root . right . right . right = new Node ( 24 ) ; root . right . left . left . left = new Node ( 1 ) ; root . right . left . left . right = new Node ( 2 ) ; root . right . left . right . left = new Node ( 3 ) ; root . right . left . right . right = new Node ( 4 ) ; root . right . right . left . left = new Node ( 5 ) ; root . right . right . left . right = new Node ( 6 ) ; root . right . right . right . left = new Node ( 7 ) ; root . right . right . right . right = new Node ( 8 ) ; x = root . right ; document . write ( " " + x . key + " " + minimumDistance ( root , x ) ) ;