On Dec 11, 11:03 am, "Miroslav Balaz" wrote:
> i think it will not perform good, if you have cards like this 1 2 3 4 5 5 5
> 5
Actually it's not all that bad in this case, it terminates when it
reaches the first occurence of 5. (1 2 3 4 5 5 5 5 5) is much
worse.
> the supposed solution is, keep
i think it will not perform good, if you have cards like this 1 2 3 4 5 5 5
5
the supposed solution is, keep one counter and one candidate
first , the candidate is the first element, and counter is 1
if the next card equals candidate increase the count to 1, else decrease it
if counter is zero you
On Dec 9, 2:22 pm, Tower <[EMAIL PROTECTED]> wrote:
> A bank has a collection of n bank cards that they’ve confiscated,
> suspecting them of being used in a fraud. Each bank card corresponds
> to a unique account in the bank. Each account can have many cards
> corresponding to it, and we’ll say
I thik it is wll known classical problem,or there is some similar well known
problem, you need O(n) comparisons.
Randomized
pick eight random cards and compare then to each other.
and you have very low probabilty that you always choose bad card.
Deterministic.
just compare 1 and second, third and f
ok, and when n is not even, you need to test explicitly the last element
with the whole cards.
2008/12/10 Miroslav Balaz <[EMAIL PROTECTED]>
> I thik it is wll known classical problem,or there is some similar well
> known problem, you need O(n) comparisons.
> Randomized
> pick eight random cards