Re: searching for missing element in an array
- From: cri@xxxxxxxx (Richard Harter)
- Date: Fri, 30 May 2008 15:30:47 GMT
On Fri, 30 May 2008 04:25:42 +0000, Richard Heathfield
<rjh@xxxxxxxxxxxxxxx> wrote:
[snip]
"The trick" is therefore guaranteed to work provided only that n(n-1)/2
does not exceed the maximum possible value for a number on the host
system.
That should be n(n+1)/2. As for my suggestion else where, the
computations should be done modulo n+2, and the requirement is
that the maximum possible value for a number be greater than
2*n+1.
Better yet, in C use unsigned arithmetic. Overflow will not
matter since the arithmetic is automatically done in modulo
arithmetic. Willem was right after all.
Richard Harter, cri@xxxxxxxx
http://home.tiac.net/~cri, http://www.varinoma.com
Save the Earth now!!
It's the only planet with chocolate.
.
- References:
- searching for missing element in an array
- From: srk
- Re: searching for missing element in an array
- From: rossum
- Re: searching for missing element in an array
- From: user923005
- Re: searching for missing element in an array
- From: CBFalconer
- Re: searching for missing element in an array
- From: user923005
- Re: searching for missing element in an array
- From: Richard Heathfield
- searching for missing element in an array
- Prev by Date: Re: Triangulation of a point cloud in OpenGL
- Next by Date: Re: searching for missing element in an array
- 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
|