-
Notifications
You must be signed in to change notification settings - Fork 312
Added a function to check ordering in ODA and DODA #344
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
Changes from 3 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
d836728
Add a function to check sorting of
Nora2412 51d7b76
Update algorithms.py
Nora2412 0b1a111
Update __init__.py
Nora2412 5150c6f
Update test_algorithms.py
Nora2412 5c6d4bd
Added is_ordered function to check order of ODA
Nora2412 69dc790
Merge branch 'pr1' of https://github.com/Nora2412/pydatastructs into pr1
Nora2412 52596f7
Update algorithms.py
Nora2412 5c352ee
Update algorithms.py
Nora2412 dbbe5a5
Minor changes
czgdp1807 8730d80
docs corrected
czgdp1807 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
from pydatastructs import ( | ||
merge_sort_parallel, DynamicOneDimensionalArray, | ||
OneDimensionalArray, brick_sort, brick_sort_parallel, | ||
heapsort, matrix_multiply_parallel, counting_sort, bucket_sort, cocktail_shaker_sort, quick_sort, longest_common_subsequence) | ||
heapsort, matrix_multiply_parallel, counting_sort, bucket_sort, cocktail_shaker_sort, quick_sort, longest_common_subsequence, is_sorted) | ||
|
||
|
||
from pydatastructs.utils.raises_util import raises | ||
|
@@ -126,3 +126,36 @@ def test_longest_common_sequence(): | |
Z = ODA(int, []) | ||
output = longest_common_subsequence(Y, Z) | ||
assert str(output) == '[]' | ||
|
||
def test_is_sorted(): | ||
ODA = OneDimensionalArray | ||
|
||
expected_result = True | ||
|
||
arr = ODA(int,[1,2,5,6]) | ||
output = is_sorted(arr,0,len(arr)-1) | ||
assert output == expected_result | ||
|
||
expected_result = False | ||
|
||
arr1 = ODA(int,[4,3,2,1]) | ||
output = is_sorted(arr1,0,len(arr1)-1) | ||
assert output == expected_result | ||
|
||
expected_result = True | ||
|
||
arr2 = ODA(int,[6,1,2,3,4,5]) | ||
output = is_sorted(arr2,1,5) | ||
assert output == expected_result | ||
|
||
expected_result = False | ||
|
||
arr3 = ODA(int,[0,-1,-2,-3,-4,4]) | ||
output = is_sorted(arr3,0,5) | ||
assert output == expected_result | ||
|
||
expected_result = True | ||
|
||
arr4 = ODA(int,[1,2,3,4,5,6,7,8,9,10]) | ||
output = is_sorted(arr4,0,9) | ||
assert output == expected_result | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apply this change whereever necessary