Skip to content

Added doctest & docstring to quadratic_probing.py #10996

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 26, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Update quadratic_probing.py
  • Loading branch information
Suyashd999 authored Oct 26, 2023
commit 1ac215b35d72f9ad87268ee5754d75cd4d2c04de
16 changes: 16 additions & 0 deletions data_structures/hashing/quadratic_probing.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,22 @@ def _collision_resolution(self, key, data=None):
>>> qp.insert_data(111)
>>> qp.keys()
{0: 0, 7: 999, 3: 111}

3. Try to add three data elements when the size is two
>>> qp = QuadraticProbing(2)
>>> qp.insert_data(0)
>>> qp.insert_data(999)
>>> qp.insert_data(111)
>>> qp.keys()
{0: 0, 4: 999, 1: 111}

4. Try to add three data elements when the size is one
>>> qp = QuadraticProbing(1)
>>> qp.insert_data(0)
>>> qp.insert_data(999)
>>> qp.insert_data(111)
>>> qp.keys()
{4: 999, 1: 111}
"""
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
"""
3. Try to add three data elements when only two were provisioned
>>> qp = QuadraticProbing(2)
>>> qp.insert_data(0)
>>> qp.insert_data(999)
>>> qp.insert_data(111)
???
"""

Copy link
Contributor Author

@Suyashd999 Suyashd999 Oct 26, 2023

Choose a reason for hiding this comment

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

@cclauss Done


i = 1
Expand Down