-2

It must be possible to traverse a list removing elements and adding some new to the begining in an efficient fashion. In C I would use a linked list,

warsaga
  • 273
  • 2
  • 11

1 Answers1

1

There are plenty of examples of LinkedList implementations in Python. I came across a good one in SO a while back... Python Linked List. If you scroll down a bit, some other users have some good implementations to follow.

Community
  • 1
  • 1
KVISH
  • 12,923
  • 17
  • 86
  • 162
  • That's assuming you want to stick to a LinkedList. But of course, your question is very broad, you can find a different way as well. – KVISH Jul 28 '12 at 23:11
  • `deque` has the performance characteristics of a linked list. – Marcin Jul 28 '12 at 23:22
  • 1
    Deque is almost what I was looking for, but how can you traverse it, with a sort of iterator. I have to perfom a complex calculation before I decide to keep an element. – warsaga Jul 29 '12 at 08:04