this may be in any of the three lang i.e c,c++,java

i have got the algo but not able to solve it :P
the question is that there may be at most 50 ballons in 3D whose coordinats should be enter by the compiler and there is a shooter who is variable who may stand at any position i.e ant x,y coordinate and any hight.

the shooter have to shoot all the ballons in the min no of bullets assuming that all the ballons are point source and the bullet can travel uptill infinity in straight ling not depend on the obstacle in its way.

we have to fing min no of bullets he have to shoot so that he may blast all the ballons in min no of bullets the shooter is variable and the ballons coordinate have to be entered by the executor and we have to get output the min no of bullets.


all of this is in 3d i.s ballond ,shooter all r in 3d and a bullet travels in straight line.

i think that this may be clrae to all of u.

this is the type of algorithm you should be using:
determine which baloon has the maximum distance from the shooter (distance formula for each balloon then sort into an array if you will)
starting with the balloons with the greatest distance from you and ending with the closest baloons.
Run a loop that moves a coordinate 1 unit at a time in a straight line towards the target baloon, checking to see if it is within the bounds of another balloon (not the target), if it is within the bounds, remove that balloon's distance from the array. When the coord reaches the target balloon, add one to the value of min no of bullets and remove that balloons value from the array.

yeah able to get the algo of the program but not be able to get the program.
and what i think that there may be 2 or all the ballons r on the same line so we have to check that and then have to check the max no of ballons then to eleminate them.
what i am abale to do is that i am able to get the max no of ballons that r blasting with that bullet but not be able to eleminate them as i am using a 3D array and if i am going in the same process then i have to consider a new 3d array for all new bullte and what i thuink that that will be wrong logic.

This article has been dead for over six months. Start a new discussion instead.