David Hláčik wrote:
Hello guys,

I have a linked list where *number of elements is unlimited* and
**last element points on random (can be first, last, in middle ,
anywhere) element within linked list** - this is important . My goals
is to create an architecture /scheme for **algoritmus which will count
total number of elements** of such linked list.
Yes , maybe it sounds strange, but we need to implement this and i
would be very gladfull for your toughts.

Python supplies a list data structure for you, so in 'normal' Python, you wouldn't bother with linked lists and all the assoicated problems.

However, if you really want:
Make a class for a list-element, with a next/prev variable (if you have a double-linked list). Instantiate as many objects as you like from that class, and let the next/prev variables from one object refer to other objects that you instantiated.
(Python doesn't care where a variable refers to.)

For the NULL value you can use None.


Sincerely,
Albert

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to