Write a program that takes an integer and gives the closest node in a binary tree.
Anonymous
Using a normal binary tree search but keep tracks of the node that has the closest value. Node find(Node n, Value v){ int gDiff = infinite; Node cNode; while( n != null){ int diff = Math.abs(n.value-v); if(diff v){ n = n.left; } }//end while return cN; }end method
Check out your Company Bowl for anonymous work chats.