Newsgroups: comp.lang.scheme
Path: cantaloupe.srv.cs.cmu.edu!bb3.andrew.cmu.edu!newsfeed.pitt.edu!scramble.lm.com!news.math.psu.edu!chi-news.cic.net!nntp.coast.net!howland.reston.ans.net!ix.netcom.com!netcom.com!NewsWatcher!user
From: hbaker@netcom.com (Henry Baker)
Subject: Re: Cycle-detection algorithm?
Message-ID: <hbaker-1902961900580001@10.0.2.15>
Sender: hbaker@netcom13.netcom.com
Organization: nil organization
References: <Dn07Dx.C6q@midway.uchicago.edu> <tonyk-1902960043360001@dial1-11.cybercom.net> <Dn1BCI.8o9@midway.uchicago.edu>
Date: Tue, 20 Feb 1996 03:00:58 GMT
Lines: 17

In article <Dn1BCI.8o9@midway.uchicago.edu>, cdjeris@midway.uchicago.edu
(Christopher Jeris) wrote:

> Thanks to all who responded, for putting up with my silly elementary
> questions.  The consensus answer was to use two pointers, one moving faster
> than the other, and see when they collide.  This works easily for lists
> which are known to be linear or cyclic.  For general list structures the
> answer is not quite so clear, but I think "two pointers" was the idea I
> needed.  Thank you!

The point isn't so much that one is 'moving faster than the other', but
that the gcd of the two speeds is 1.

-- 
www/ftp directory:
ftp://ftp.netcom.com/pub/hb/hbaker/home.html

