Skip to content
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

fixes:#603 Radix Sort #618

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

VAIBHAVSING
Copy link

Implementation of Radix Sort

implement radix sort in pydatastructs/linear_data_structures/algorithms.py file

Fixes #1234

Testing of this Radix sort

def test_basic_sort():
# Test basic sorting
arr = OneDimensionalArray(int, [170, 45, 75, 90, 802, 24, 2, 66])
out = radix_sort(arr)
result = [out[i] for i in range(len(out))]
expected = [2, 24, 45, 66, 75, 90, 170, 802]
print(f"Result: {result}")
print(f"Expected: {expected}")
assert result == expected
print("Basic sort test passed!")

# Test with None values
arr = OneDimensionalArray(int, [45, None, 12, None, 89])
out = radix_sort(arr)
result = [out[i] for i in range(len(out)) if out[i] is not None]
expected = [12, 45, 89]
print(f"\nResult with None: {result}")
print(f"Expected: {expected}")
assert result == expected
print("None values test passed!")

if name == 'main':
test_basic_sort()

@asmit27rai
Copy link

@VAIBHAVSING Pls make sure it will pass all checks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants