-
Notifications
You must be signed in to change notification settings - Fork 271
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
Adding Longest Common Subsequence #315
Merged
Merged
Changes from 74 commits
Commits
Show all changes
77 commits
Select commit
Hold shift + click to select a range
5b34a79
Update queue.py
Arvind-raj06 52f01c3
Update linked_lists.py
Arvind-raj06 6610a7f
Update linked_lists.py
Arvind-raj06 4c5c855
Update linked_lists.py
Arvind-raj06 f93008a
Update queue.py
Arvind-raj06 6867add
Update linked_lists.py
Arvind-raj06 628045c
Update linked_lists.py
Arvind-raj06 09e5e42
Completed updating the insert_after
Arvind-raj06 74009e6
Update linked_lists.py
Arvind-raj06 0055baa
Update queue.py
Arvind-raj06 9dec38c
Update linked_lists.py
Arvind-raj06 708f6bc
Cocktail
Arvind-raj06 27a5f1a
Update algorithms.py
Arvind-raj06 6ae5a0c
Implementing the cocktail sort
Arvind-raj06 aaf529a
Update __init__.py
Arvind-raj06 9f937d4
Correcting error
Arvind-raj06 38ebcbe
Completion
Arvind-raj06 9a77768
Converting to ODA
Arvind-raj06 40350b4
Update algorithms.py
Arvind-raj06 a049c11
Update algorithms.py
Arvind-raj06 a990d46
Really!
Arvind-raj06 e49d268
Including cocktail sort
Arvind-raj06 c6c5fdd
Correcting for doda
Arvind-raj06 db70e68
Error Correction
Arvind-raj06 9acbebf
Yep done!
Arvind-raj06 57d7fbf
Hope this works fine
Arvind-raj06 3569652
Update algorithms.py
Arvind-raj06 c9d4f9c
Commit
Arvind-raj06 e1d817f
Cocktail update
Arvind-raj06 864e95c
Update algorithms.py
Arvind-raj06 570a287
Update test_algorithms.py
Arvind-raj06 cf91f8a
Let's check
Arvind-raj06 3c34257
Update test_algorithms.py
Arvind-raj06 1ae0e3d
Update test_algorithms.py
Arvind-raj06 89b903a
Fixed cocktail sort
czgdp1807 7a4581c
cocktail_sort -> cocktail_shaker_sort
czgdp1807 0c741ca
Starting with Quicksort
Arvind-raj06 4835dd4
Adding quick sort
Arvind-raj06 069613a
Making changes
Arvind-raj06 3f97409
Update algorithms.py
Arvind-raj06 2177e04
Update __init__.py
Arvind-raj06 7e23b41
Hope this works
Arvind-raj06 abe4362
Update algorithms.py
Arvind-raj06 0ad0b56
Update algorithms.py
Arvind-raj06 4e1e8d4
Ok
Arvind-raj06 f8afd26
Update algorithms.py
Arvind-raj06 377bfd6
added quick sort
Arvind-raj06 a1fd65a
Merge branch 'master' into Let'scode
Arvind-raj06 7c4d918
Update algorithms.py
Arvind-raj06 c042722
Removing whitespace
Arvind-raj06 ed7a059
Error correction
Arvind-raj06 9cda682
Start to implement stack
Arvind-raj06 65d0f88
Hope this work
Arvind-raj06 f22a7ac
Update algorithms.py
Arvind-raj06 5da091e
Yep
Arvind-raj06 2c7afac
Forgot
Arvind-raj06 e8d13b0
Shifting None to end
czgdp1807 f7c6463
Restored test
czgdp1807 b476021
Apply suggestions from code review
czgdp1807 923b1be
Yes Done
Arvind-raj06 bcb678e
Pivot picking logic corrected
czgdp1807 a6fec40
Completed
Arvind-raj06 bc6cd31
Merge branch 'master' into Don'tstop
Arvind-raj06 96067eb
Error Correction
Arvind-raj06 6df16fb
Merge branch 'Don'tstop' of https://github.com/Arvind-raj06/pydatastr…
Arvind-raj06 a73bc25
Yep
Arvind-raj06 07fc3e9
Update algorithms.py
Arvind-raj06 86f389c
Update algorithms.py
Arvind-raj06 60cfdc2
Merge branch 'Don'tstop' of https://github.com/Arvind-raj06/pydatastr…
Arvind-raj06 8c26960
Implement
Arvind-raj06 699b3b2
Update algorithms.py
Arvind-raj06 0ae9085
Update algorithms.py
Arvind-raj06 90f1089
Yes added
Arvind-raj06 2196ec2
Update algorithms.py
Arvind-raj06 2766287
Implemented
Arvind-raj06 a85e08b
Added tests and fixed docs
czgdp1807 478bf66
fixed docs
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 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 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 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,8 @@ | ||
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) | ||
heapsort, matrix_multiply_parallel, counting_sort, bucket_sort, cocktail_shaker_sort, quick_sort, longest_common_subsequence) | ||
|
||
|
||
from pydatastructs.utils.raises_util import raises | ||
import random | ||
|
@@ -100,3 +101,22 @@ def test_matrix_multiply_parallel(): | |
J = [[2, 1, 2], [1, 2, 1], [2, 2, 2]] | ||
output = matrix_multiply_parallel(I, J, num_threads=1) | ||
assert expected_result == output | ||
|
||
def test_longest_common_sequence(): | ||
expected_result = (5, 'ASCII') | ||
|
||
str1, str2 = 'AASCCII', 'ASSCIIII' | ||
output = longest_common_subsequence(str1, str2) | ||
assert expected_result == output | ||
|
||
expected_result = (3, ['O', 'V', 'A']) | ||
|
||
I, J = ['O', 'V', 'A', 'L'], ['F', 'O', 'R', 'V', 'A', 'E', 'W'] | ||
output = longest_common_subsequence(I, J) | ||
assert expected_result == output | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add one test case for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah sure that can be done |
||
|
||
expected_result = (2, ('O', 't')) | ||
|
||
I, J = ('K', 'O', 't', 'H', 'E'), ('L', 'O', 'C', 't') | ||
output = longest_common_subsequence(I, J) | ||
assert expected_result == output |
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.
This part is cryptic. We should keep the input types restricted to
OneDimensionalArray
only, otherwise such things will create problems while porting the code to statically typed languages like C++.In addition, applying longest common subseqeunce on strings would be confusing because there is already something called longest common substring.
Hence the final API should be, accept two
OneDimensionalArray
objects and return aOneDimensionalArray
.P.S. That is why doing some background lookups are preferred for discussing APIs rather than just directly coding out things and keep changing frequently.
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.
Yeah next time onwards we discuss and start the implementation and I will try to implement the above in One dimensional