London | 26-SDC-March | Zobeir Rigi | Sprint 2 | Implement a skip list - #208
London | 26-SDC-March | Zobeir Rigi | Sprint 2 | Implement a skip list#208Zobeir-Rigi wants to merge 2 commits into
Conversation
cjyuan
left a comment
There was a problem hiding this comment.
What you implemented is not quite a "Skip List".
May I suggest search for Skip List pseudo code, and then convert the pseudo code to Python? There may be more than one way to implement Skip List, so look for something you can understand.
This video gives a good illustration of how Skip List works, but it does not include any pseudo code: https://www.youtube.com/watch?v=UGaOXaXAM5M
| else: | ||
| right = mid | ||
|
|
||
| self.items.insert(left, value) |
There was a problem hiding this comment.
The complexity of Python's list.insert() method is
There was a problem hiding this comment.
The complexity of Python's list.insert() method is O ( n ) in the worst case.
YES, You're right. I used binary search to find the insertion position, but I overlooked the fact that Python's list.insert() still has O(n) complexity because elements may need to be shifted. This means my implementation does not achieve the insertion complexity expected from a true Skip List.
Yes, my original implementation was a sorted list with binary search rather than a true Skip List structure. After reviewing how Skip Lists work, I understand that they use nodes, multiple levels and forward links to allow faster searches and insertions. I just updated my solution to better match the Skip List data structure. |
|
LGTM. |
I originally completed all the Sprint 2 exercises in one PR, but the validation expected separate PRs for each issue. This PR contains only the solution for the "Implement a skip list" exercise.
Implemented the required skip list functionality, including:
All provided tests pass.