Bloomberg LP Interview Question
Financial Software DevelopersAccording to Gautam -
2 * sqrt { r*r + (r/2)*(r/2) }
= 2 * sqrt { r*r + r*r / 4 }
= 2 * sqrt { r*r *( 5 /4 ) }
= 2 * r * sqrt (5/4)
= r * sqrt (5)
~ r * 2.2360679774997896964091736687313
Accroding to Mandar -
r *(1 + sqrt (2))
~ r * 2.4142135623730950488016887242097
So mandar's way of calculating along surface digonal is not shortest. He should calculate from vertex to mid of any of the adjusant edge of the opposite vertex of that surface and then from there to the oppsite vertex.
for simplicity take a thread and simple cube and try how that thread want's to travel when you tie it from one vertex to another, it will stay on any side of the cube but will sleep down to the mid of the edge.
This is a very old question. And the correct question has no calculus of other big math things in it. The solution has been given. Imagine the cube to be a flat surface. As if the cube is a room/box and all its side are put flat. Now use SIMPLE Pythagorus theorem to get the answer as sqrt(side*side + side*side)
Companies like these do not want Calculas and integration solutions. Simple solutions.
since we can only traverse thru the surface so it has to be sqrt(2)+1,but along the diagonal i.e. interior wud be sqrt(5)
No. Here are all answers for all possible cases.
(Note : I have taken 'r' as side length of the cube.
Interior(If you cut through): srqoot(3)*r
Exterior(Along Edges):3*r
Exterior(shortest along the surface):sqroot(5)*r
Heretic and gouti are correct!
"how do you find the shortest distance (find a formula) for two points on the opposite vertices of a cube (shortest distance is actually sqrt(3) but can't cut through interior, must go along surface of cube)"
Shortest dist sqrt(3) means here the points should be end points of the diagonal. If we cant go through a diagonal (of a cube which is not present in any surface), then we must go through one diagonal of a surface (side*sqrt(2)) and one side.
So answer is (1+sqrt(2))*side
do it using calculus, guys.
suppose you are finding the shortest between A and B, I set a point C in the opposite side of A, whose distance to nearest end is x. Then the distance is
dist = sqrt(a^2+x^2) + sqrt(2a^2-x^2)
ask ddist/dx=0 to obtain the min value. Then x = a/sqrt(2)
and dist = a*sqrt(6)
=======================================================
however, this is the MAX distance, the MIN one is a*sqrt(5)
Imagine that the cube was a cardboard box, and the box could be opened to make the cardboard sheet. now connect the opposite points. the diagonal is the shortest path.
- champaklal June 17, 2010