On the complexity of determining whether n numbers are distinct
- From: "eKo1" <berndlosert@xxxxxxxxxxxx>
- Date: 24 Sep 2006 12:26:15 -0700
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.
.
- Follow-Ups:
- Re: On the complexity of determining whether n numbers are distinct
- From: Googmeister
- Re: On the complexity of determining whether n numbers are distinct
- From: Googmeister
- Re: On the complexity of determining whether n numbers are distinct
- From: Markus Triska
- Re: On the complexity of determining whether n numbers are distinct
- Prev by Date: Re: An algorithm with Minimum vertex cover without considering its performance
- Next by Date: Re: An algorithm with Minimum vertex cover without considering its performance
- Previous by thread: An algorithm with Minimum vertex cover without considering its performance
- Next by thread: Re: On the complexity of determining whether n numbers are distinct
- Index(es):
Relevant Pages
|