Skip to content

London | 26-SDC-March | Zobeir Rigi | Sprint 2 | Implement a skip list - #208

Open
Zobeir-Rigi wants to merge 2 commits into
CodeYourFuture:mainfrom
Zobeir-Rigi:implement-skip-list
Open

London | 26-SDC-March | Zobeir Rigi | Sprint 2 | Implement a skip list#208
Zobeir-Rigi wants to merge 2 commits into
CodeYourFuture:mainfrom
Zobeir-Rigi:implement-skip-list

Conversation

@Zobeir-Rigi

Copy link
Copy Markdown
  • I have titled my PR with Region | Cohort | FirstName LastName | Sprint | Assignment Title
  • My changes meet the requirements of the task
  • I have tested my changes
  • My changes follow the style guide

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:

  • insert
  • contains checks
  • conversion to a list

All provided tests pass.

@Zobeir-Rigi Zobeir-Rigi added 📅 Sprint 2 Assigned during Sprint 2 of this module Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. Module-Complexity The name of the module. labels Jul 6, 2026

@cjyuan cjyuan left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The complexity of Python's list.insert() method is $O(n)$ in the worst case.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@cjyuan cjyuan added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Jul 9, 2026
@Zobeir-Rigi

Copy link
Copy Markdown
Author

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

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.

@cjyuan

cjyuan commented Jul 17, 2026

Copy link
Copy Markdown

LGTM.

@cjyuan cjyuan added Complete Volunteer to add when work is complete and all review comments have been addressed. and removed Reviewed Volunteer to add when completing a review with trainee action still to take. labels Jul 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Complete Volunteer to add when work is complete and all review comments have been addressed. Module-Complexity The name of the module. 📅 Sprint 2 Assigned during Sprint 2 of this module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants