E
E
Ekalips2015-04-07 19:33:07
Programming
Ekalips, 2015-04-07 19:33:07

How to find a radioactive ball?

Hello.
Recently, I was given a task that sounded like this: "There is a box, there is a Geiger counter. There are 100 balls in the box and one of them is radioactive. Find the last one using the branch and bound method." It was necessary to write this code in Pascal. To be honest, I was not familiar with the branch and bound method, or simply did not remember at that moment.
How it happened for me: an array is created in which one of the 100 elements = 100, while the rest decrease by one as they move away from it (it is logical, the farther from the radioactive one, the less radioactivity). Next, I looked at the first and last element in the subset and, depending on which of the elements is larger, cut off half of the subset "on the other side".
Tobish:
95 96 97 98 99 100 99 98
95<98, so we cut off the left side and it remains
99 100 99 98 ... and so on.
When providing the result, I was told that this is **** and I need to do it differently.
Here's how in another way: "There is a matrix, it contains all ones and 1 zero, and we don't know where this zero is, then we need to select 1 column and one row ...."
How to do this? Or was my choice correct?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Rulev, 2015-04-07
@Ekalips

If you have a matrix in which only one element differs from the others and that element does not glow in any way, no ***** branch and bound method is needed and you just need to go through the loop and find it (and this is the only optimal way to do this, any other methods will only increase the time (except for proper parallelization)). In an example with values ​​​​decreasing in both directions, an interpolation search
adapted for this would work well .

U
uvelichitel, 2015-04-07
@uvelichitel

Divide the balls into two piles, select the poisonous one with a counter. Repeat the procedure with poisonous until victory.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question