Re: Looking for a fast algorithm
- From: wade@xxxxxxxxxx
- Date: 19 Jan 2006 07:27:18 -0800
frederik_coppens@xxxxxxxxx wrote:
> I have the following problem. I have rows of objects, each if which is
> associated with a number. The rows are of different length. The objects
> on each row are sorted, the objects with the highest numbers come
> first.
> Now, it's possible to make sequences of objects by taking an object
> from every row, and to associate a number with each such sequence by
> multiplying the numbers of every object. It's clear that the sequence
> with the highest number will be the one obtained by taking the first
> object of every row. But how do I find the X highest sequences? (ie the
> X sequences with the highest numbers, where X can be for example 100.)
> It's of course possible with brute force search, but Is there a fast
> algorithm for doing this?
> Thanks,
Observe that after the first sequence, each new sequence will be
different in only row from some previously selected sequence. If
multiplication/division is O(1), and you have k rows, you can find the
top X sequences in O(Xk log(Xk)) time.
My statement, and your 'it's clear' statement both assume that
a>=b,c>=d implies ac>=bd, which puts some restrictions on the numbers.
.
- References:
- Looking for a fast algorithm
- From: frederik_coppens
- Looking for a fast algorithm
- Prev by Date: Re: Is there an EXPSPACE complete language?
- Next by Date: Re: Is there an EXPSPACE complete language?
- Previous by thread: Re: Looking for a fast algorithm
- Next by thread: Help!! Random Integer Generator Algorithm
- Index(es):
Relevant Pages
|