Skip to content

London | 26-SDC-Mar | Ebrahim Beiati-Asl | Sprint 2 | implement_skip_list#155

Open
ebrahimbeiati wants to merge 1 commit into
CodeYourFuture:mainfrom
ebrahimbeiati:skip_list_pr
Open

London | 26-SDC-Mar | Ebrahim Beiati-Asl | Sprint 2 | implement_skip_list#155
ebrahimbeiati wants to merge 1 commit into
CodeYourFuture:mainfrom
ebrahimbeiati:skip_list_pr

Conversation

@ebrahimbeiati
Copy link
Copy Markdown

Learners, PR Template

Self checklist

  • 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

@ebrahimbeiati ebrahimbeiati added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Apr 16, 2026
Copy link
Copy Markdown

@cjyuan cjyuan left a comment

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 typical SkipList. In particular, your insertion operation is O(n) whereas the insertion cost of a SkipList is O(log n).

A SkipList should be linked list-liked data structure.


if pos < len(self.data) and self.data[pos] == value:
return # value already exists, do not insert duplicates
self.data.insert(pos, 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.

This insertion operation is O(n), which does not meet the requirement.

@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 May 17, 2026
@ebrahimbeiati ebrahimbeiati added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label May 19, 2026
Copy link
Copy Markdown

@cjyuan cjyuan left a comment

Choose a reason for hiding this comment

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

What you implemented does not look like 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

Comment on lines +16 to +23
def _get_node(self, index):
"""Get the node at the given index."""
current = self.head
for _ in range(index):
if current is None:
return None
current = current.next
return current
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This function performs a linear traversal on the linked list from head.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

When index is close to n, this function has to traverse about n nodes to reach current.

The complexity of a function calling this function will be at least O(n).

Comment on lines +41 to +46
for i in range(len(self.skips) - 1):
a = self.skips[i]
b = self.skips[i + 1]

node_a = self._get_node(a)
node_b = self._get_node(b)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This loop, together with the linear traversal performed by _get_node(pos), suggests a complexity of worse than O(n).

@cjyuan cjyuan removed the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label May 19, 2026
@ebrahimbeiati ebrahimbeiati added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label May 20, 2026
Copy link
Copy Markdown

@cjyuan cjyuan left a comment

Choose a reason for hiding this comment

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

Your implementation does not look like a typical Skip List. I don't think you can make it a Skip List by making some changes.

I would suggest try to understand how Skip List works first, then study the pseudo code of a Skip List, and then reimplement it from the beginning.

Comment on lines +16 to +23
def _get_node(self, index):
"""Get the node at the given index."""
current = self.head
for _ in range(index):
if current is None:
return None
current = current.next
return current
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

When index is close to n, this function has to traverse about n nodes to reach current.

The complexity of a function calling this function will be at least O(n).

@cjyuan cjyuan removed the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label May 20, 2026
@ebrahimbeiati ebrahimbeiati added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label May 20, 2026
@github-actions

This comment has been minimized.

@github-actions github-actions Bot removed the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label May 20, 2026
@ebrahimbeiati ebrahimbeiati added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label May 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. Reviewed Volunteer to add when completing a review with trainee action still to take.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants