Skip to content

Implement skip list#4

Open
AliQassab wants to merge 2 commits intomainfrom
implement-skip-list
Open

Implement skip list#4
AliQassab wants to merge 2 commits intomainfrom
implement-skip-list

Conversation

@AliQassab
Copy link
Copy Markdown
Owner

@AliQassab AliQassab commented Mar 8, 2026

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

Changelist

Briefly explain your PR.

Questions

Ask any questions you have for your reviewer.

@AliQassab AliQassab added the needreview PR is pending AI review label Mar 8, 2026
@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 8, 2026

Your PR couldn't be matched to an assignment in this module.

Please check its title is in the correct format, and that you only have one PR per assignment.

If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed).

If this PR needs reviewed, please add the 'Needs Review' label to this PR after you have resolved the issues listed above.

5 similar comments
@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 8, 2026

Your PR couldn't be matched to an assignment in this module.

Please check its title is in the correct format, and that you only have one PR per assignment.

If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed).

If this PR needs reviewed, please add the 'Needs Review' label to this PR after you have resolved the issues listed above.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 8, 2026

Your PR couldn't be matched to an assignment in this module.

Please check its title is in the correct format, and that you only have one PR per assignment.

If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed).

If this PR needs reviewed, please add the 'Needs Review' label to this PR after you have resolved the issues listed above.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 8, 2026

Your PR couldn't be matched to an assignment in this module.

Please check its title is in the correct format, and that you only have one PR per assignment.

If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed).

If this PR needs reviewed, please add the 'Needs Review' label to this PR after you have resolved the issues listed above.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 8, 2026

Your PR couldn't be matched to an assignment in this module.

Please check its title is in the correct format, and that you only have one PR per assignment.

If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed).

If this PR needs reviewed, please add the 'Needs Review' label to this PR after you have resolved the issues listed above.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 8, 2026

Your PR couldn't be matched to an assignment in this module.

Please check its title is in the correct format, and that you only have one PR per assignment.

If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed).

If this PR needs reviewed, please add the 'Needs Review' label to this PR after you have resolved the issues listed above.

@AliQassab AliQassab closed this Mar 8, 2026
@AliQassab AliQassab reopened this Mar 8, 2026
@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 8, 2026

Your PR couldn't be matched to an assignment in this module.

Please check its title is in the correct format, and that you only have one PR per assignment.

If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed).

If this PR needs reviewed, please add the 'Needs Review' label to this PR after you have resolved the issues listed above.

@AliQassab AliQassab closed this Mar 8, 2026
@AliQassab AliQassab reopened this Mar 8, 2026
@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 8, 2026

Your PR couldn't be matched to an assignment in this module.

Please check its title is in the correct format, and that you only have one PR per assignment.

If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed).

If this PR needs reviewed, please add the 'Needs Review' label to this PR after you have resolved the issues listed above.

@AliQassab AliQassab closed this Mar 8, 2026
@AliQassab AliQassab reopened this Mar 8, 2026
@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 8, 2026

Your PR couldn't be matched to an assignment in this module.

Please check its title is in the correct format, and that you only have one PR per assignment.

If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed).

If this PR needs reviewed, please add the 'Needs Review' label to this PR after you have resolved the issues listed above.

@AliQassab AliQassab closed this Mar 8, 2026
@AliQassab AliQassab reopened this Mar 8, 2026
@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 8, 2026

Your PR couldn't be matched to an assignment in this module.

Please check its title is in the correct format, and that you only have one PR per assignment.

If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed).

If this PR needs reviewed, please add the 'Needs Review' label to this PR after you have resolved the issues listed above.

Copy link
Copy Markdown

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Good implementation overall! All tests pass and complexity requirements are met. One minor code quality note below.

self.max_level = 16
self.head = SkipListNode(float('-inf'), self.max_level)
self.level = 0

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 line reassigns current to current.forward[0], but the variable is never read again — making it dead code. It looks like a leftover from a duplicate-check pattern. Since the assignment doesn't require uniqueness you can safely remove this line, or if you do want to guard against duplicates you could add:

Suggested change
current = current.forward[0]
if current is not None and current.value == value:
return # value already exists, skip duplicate

Either way, leaving an unused variable assignment makes the code harder to read and may mislead future readers into thinking the value is checked.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 8, 2026

Code Review Summary

What the trainee did: Implemented a skip list data structure from scratch in Python, supporting insert, contains, and to_list operations, plus a __contains__ dunder method for natural in operator support.

What was done well:

  • All provided tests pass (both test_single_item and test_general_usage).
  • Complexity requirements are met: insert and contains are O(log n) average time, and to_list is O(n).
  • The randomised level generation (_random_level) correctly uses a coin-flip approach, giving the expected probabilistic balance.
  • The update array pattern for tracking predecessors at each level is correct and idiomatic for skip list implementations.
  • Good use of float('-inf') as the sentinel head value.
  • Clean code structure with docstrings on each method.

What needs improvement:

  • Line 34 — dead code: current = current.forward[0] reassigns the variable but it is never read again. This is most likely a remnant of a duplicate-value guard that was never finished. It does not break anything, but it adds confusion. Either remove it or complete the duplicate check (see inline comment).
  • No duplicate handling: Inserting the same value twice will silently add two copies, and to_list will return duplicates. This isn't tested in the provided tests and the README doesn't explicitly require uniqueness, but it is worth being aware of.

Overall this is a solid, working skip list implementation. Nice work!

VERDICT: completed

@github-actions github-actions bot added completed Code is correct and meets quality standards and removed needreview PR is pending AI review labels Mar 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

completed Code is correct and meets quality standards

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant