Search Algo
Hi all,
I am sure this question may turn out to be a trivial one for some, but not to me :). I will try to represent the problem in the following example:
There are a group of 'marbles', distributed over a line of length 100cm. The total number of the marbles, their distribution, distance from each other, ...are all unknown. Each marble occupies a 2cm space on the line. Marbles do not overlap, but can be next to each other.
1) I need to select a segment of that line, of constant length x (e.g. 30 cm), that covers as many as possible of the total number of marbles on that line. A marble is counted 'in' when all of it is in.
2) Another flavor to the problem: The center of the new segment should be at the center of one of the marbles on the line. Its also better for the marbles to be centrally located on the new segment. (For example, if there are three marbles, and all are covered by the new segment, its better for the center of the new segment to match the center of the middle marble. )
But just for the first question, I would appreciate if someone can point me to an algorithm, some pseudocode, or some freely available java implementation if any.
Thanks a lot.

