# Re: find a number

*From*: Steve O'Hara-Smith <steveo@xxxxxxxxxx>*Date*: Fri, 24 Mar 2006 22:23:57 +0000

On Fri, 24 Mar 2006 19:12:35 GMT

Mark P <usenet@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote:

There's also a cute algorithm for this problem which runs in linear

time, uses constant space, and performs no arithmetic computations on

the array elements.

I think this works.

while (1)

{

v = a[0];

if (a[v] == v)

return v;

a[0] = a[v]

a[v] = v;

}

--

C:>WIN | Directable Mirror Arrays

The computer obeys and wins. | A better way to focus the sun

You lose and Bill collects. | licences available see

| http://www.sohara.org/

.

**Follow-Ups**:**Re: find a number***From:*Logan Shaw

**References**:**find a number***From:*murali@pune

**Re: find a number***From:*Sc0rpi0

**Re: find a number***From:*Mark P

- Prev by Date:
**Re: Checking for Modification to a Set of Files** - Next by Date:
**Re: What is use the of Pragma directives!!!** - Previous by thread:
**Re: find a number** - Next by thread:
**Re: find a number** - Index(es):