Re: On the complexity of determining whether n numbers are distinct
- From: "Googmeister" <googmeister@xxxxxxxxx>
- Date: 25 Sep 2006 07:15:22 -0700
eKo1 wrote:
There are two algorithms I can think of that determines whether n
numbers are distinct:
1. Compare each number with every other number. If you find two that
are the same, the numbers are not distinct.
2. Sort the numbers. Loop through the sorted list and if you find that
the ith and (i + 1)th entries in the list are the same, the numbers are
not distinct.
The number of comparisons in the first algorithm is proportional to n^2
and in the second to n lg n in the worst-case (viz. that all numbers
are distinct).
I want to prove that any algorithm A, in the worst-case, has to do at
least a number of comparison s proportional to n lg n. I've read that
this can be shown by reducing the problem to one of sorting but the
proof is bogus because it takes A, changes it to A' (which does
sorting) and then incorrectly states that both A and A' contain the
same number of comparisons.
Before proving it, you have to be precise about your model of
computation, e.g., what operations are permitted. The paper "Lower
bounds for algebraic computation trees" by Michael Ben-Or proves the n
log n lower bound in the algebraic decision tree model of computation.
.
- Follow-Ups:
- References:
- Prev by Date: Re: More beginner questions about SAT...
- Next by Date: Re: On the complexity of determining whether n numbers are distinct
- Previous by thread: Re: On the complexity of determining whether n numbers are distinct
- Next by thread: Re: On the complexity of determining whether n numbers are distinct
- Index(es):
Relevant Pages
|