Re: searching for missing element in an array
- From: pete <pfiland@xxxxxxxxxxxxxx>
- Date: Fri, 30 May 2008 03:18:06 -0500
Juha Nieminen wrote:
Ico wrote:Juha Nieminen <nospam@xxxxxxxxxxxxxx> wrote:Ico wrote:See rossum's reply, he explains the algorithm there.For example, can you tell in advance what the sum of allI fail to understand how that is relevant to the problem in question.
numbers [1..n] is, without actually adding them all up ?
Yes, being able to calculate the sum of integers 1-n without doing an
explicit loop is faster, but it doesn't change the O(n) complexity of
the requested algorithm.
That didn't answer my question. His algorithm is still O(n) regardless
of whether you calculate the sum of integers between 1 and n with a
mathematical formula or in a loop.
Your question seems strange.
You are asking about the relevance of an O(n) solution
to a problem which requires an O(n) solution.
--
pete
.
- References:
- searching for missing element in an array
- From: srk
- Re: searching for missing element in an array
- From: Ico
- Re: searching for missing element in an array
- From: SRK
- Re: searching for missing element in an array
- From: Ico
- Re: searching for missing element in an array
- From: Juha Nieminen
- Re: searching for missing element in an array
- From: Ico
- Re: searching for missing element in an array
- From: Juha Nieminen
- searching for missing element in an array
- Prev by Date: Re: searching for missing element in an array
- Next by Date: Re: any luck with freelance work on the Internet?
- Previous by thread: Re: searching for missing element in an array
- Next by thread: Re: searching for missing element in an array
- Index(es):
Relevant Pages
|