linked list with cycle structure
Diez B. Roggisch
deets at nospam.web.de
Thu Jan 8 11:48:39 EST 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.
Diez
More information about the Python-list
mailing list