0

I was wondering how to implement a skip list in python.

I have made a linked list but I'm having trouble on how to create the different levels of a linked list and how i would go about iterating through every level of the list when searching or inserting nodes into the list.

Community
  • 1
  • 1
kyle truong
  • 33
  • 1
  • 4
  • 2
    What's your question? – wRAR Feb 27 '13 at 20:01
  • You need to describe clearly (may be with some code samples) what you've done so far and what is the problem/question that you're stuck at, instead of phrasing a very general and vague question. – Tuxdude Feb 27 '13 at 20:22
  • That's the thing, I don't have any code for it, I'm not sure how to do it because our prof never taught us how to make a link list. – kyle truong Feb 27 '13 at 22:46

1 Answers1

12

You can read John Shipman's nicely-written pure-Python implementation, which even includes detailed explanations on how he built it, from the top-level design down to how the classes were implemented, including things like a discussion on how to provide a nice Pythonic interface.

You can also search PyPI, where there are multiple additional implementations.

Or you can read the Wikipedia entry or the original paper, both of which have detailed explanations and pseudocode that you can translate into Python.

Your existing question is way too general. But if, after reading the relevant information, you have specific questions ("What does this part of Shipman's code do", "What does this line of pseudocode in Pugh's paper means, and how do I translate it to Python", "What exactly is a 'cut list'", etc.), then you can ask on SO.

abarnert
  • 354,177
  • 51
  • 601
  • 671