Hi guys, I am attempting to modify the selection algorithm to work with the following situation:
My imput is a list of numbers x1, x2, ... , xn (not necessarily ordered).
Each of these numbers has a weight "w". I call W the sum of all the weights.
If I provide a value X, which is greater than 0 but no larger than W, how can I find a xi, such that the sum of the weights of all x's with index greater than i is less than X, and xi's weight + sum of the weights of all items with index greater than i is greater than or equal to X.
This is easily accomplished if we sort all the x's according to their index, but I wish to do that without sorting.