linked list with cycle structure

Diez B. Roggisch deets at
Thu Jan 8 17:48:39 CET 2009

David Hláčik wrote:

> Hi,
> so okay, i will create a helping set, where i will be adding elements
> ID, when element ID will be allready in my helping set i will stop and
> count number of elements in helping set. This is how long my cycled
> linked list is.
> But what if i have another condition , and that is *i can use only
> helping memory with constant size* ? This means i am not able to
> create any set and adding elements there. I need to have a constant
> size variables . This is complication a complication for me.

This isn't to hard - think about what you are really interested in - knowing
if *all* other elements are already counted, or a specific one? You can get
away with only one, to detect the cycle and abort.


More information about the Python-list mailing list