sandeepgiri
BAN USER
Comments (3)
Reputation 50
Page:
1
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
0
of 0 vote
Is it similar to question with id 11879708? I am not able to post the link.
- sandeepgiri February 29, 2012Comment hidden because of low score. Click to expand.
0
of 0 vote
//example call: findClosest(t, 4.1, MAX_DOUBLE);
double findClosest(Node t, double value, double closestSofar)
{
if(delta(value, t.value) < delta(value, closestSofar))
{
closestSofar = t.value;
}
if(t.value < value)
{
closestSofar = findClosest(t.right, value, closestSofar);
}
else
{
closestSofar = findClosest(t.left, value, closestSofar);
}
return closestSofar;
}
private double delta(double value, double value2) {
double d = value - value2;
if(d < 0)
return -1*d;
return d;
}
Page:
1
CareerCup is the world's biggest and best source for software engineering interview preparation. See all our resources.
In Python:
- sandeepgiri February 27, 2014