pre-commit-ci[bot]
8dcffa3e71
[pre-commit.ci] auto fixes from pre-commit.com hooks
...
for more information, see https://pre-commit.ci
2024-10-19 08:21:25 +00:00
Putul Singh
a4073ca188
suffix_array_lcp.py
2024-10-19 13:49:17 +05:30
pre-commit-ci[bot]
1b37c1c127
[pre-commit.ci] auto fixes from pre-commit.com hooks
...
for more information, see https://pre-commit.ci
2024-10-19 08:18:10 +00:00
Putul Singh
8b0e74e81c
suffix_array_lcp.py
2024-10-19 13:46:04 +05:30
pre-commit-ci[bot]
8038826cd9
[pre-commit.ci] auto fixes from pre-commit.com hooks
...
for more information, see https://pre-commit.ci
2024-10-19 08:11:54 +00:00
Putul Singh
c7f137eefc
suffix_array_lcp.py
2024-10-19 13:40:04 +05:30
pre-commit-ci[bot]
70c3869f42
[pre-commit.ci] auto fixes from pre-commit.com hooks
...
for more information, see https://pre-commit.ci
2024-10-19 07:53:46 +00:00
Putul Singh
dae072c0c7
Suffix Array and LCP Array Implementation
2024-10-19 13:23:23 +05:30
Putul Singh
d950f5740b
Delete divide_and_conquer/Suffix Array and LCP implementation.py
2024-10-19 13:22:59 +05:30
pre-commit-ci[bot]
848a358d80
[pre-commit.ci] auto fixes from pre-commit.com hooks
...
for more information, see https://pre-commit.ci
2024-10-19 07:13:23 +00:00
Putul Singh
123e6f0c33
Suffix Array and LCP implementation.py
2024-10-19 12:39:41 +05:30
pre-commit-ci[bot]
0094577a48
[pre-commit.ci] auto fixes from pre-commit.com hooks
...
for more information, see https://pre-commit.ci
2024-10-19 06:54:38 +00:00
Putul Singh
1e8f767d3c
Added Suffix Array and LCP implementation
2024-10-19 12:20:31 +05:30
Putul Singh
06a7be7ba0
Delete divide_and_conquer/Suffix Array and LCP implementation.py
2024-10-19 12:10:54 +05:30
Putul Singh
6132d40a37
Suffix Array and LCP implementation.py
...
This code file provides an implementation of Suffix Arrays and Longest Common Prefix (LCP) Arrays in Python, designed as a contribution to the open-source community during Hacktoberfest 2024.
Overview:
A suffix array is an essential data structure used in many string-processing algorithms. It provides an efficient way to store and sort all possible suffixes of a given string. This project also includes the construction of the LCP array, which records the lengths of the longest common prefixes between consecutive suffixes in the sorted suffix array. Together, these two arrays form the backbone of many algorithms in text processing and pattern matching.
Key Features:
Suffix Array Construction: A suffix array is built by sorting all suffixes of the input string in lexicographical order and storing their starting indices.
LCP Array Construction: The LCP array is computed using an efficient algorithm that compares consecutive suffixes from the suffix array and records the length of their common prefixes.
Optimized Approach: The approach used in this implementation ensures efficient computation of both suffix and LCP arrays with a linear-time construction of the LCP array following the suffix sorting.
User-friendly Display: The program clearly displays both the suffix and LCP arrays, allowing users to easily visualize and understand the results for any given input string.
Why this Contribution?
As part of Hacktoberfest 2024, I wanted to contribute something that could be useful for developers and researchers working with text-processing algorithms. This implementation not only helps in better understanding of basic string operations but also serves as a building block for more complex algorithms in fields like bioinformatics, data compression, and natural language processing.
Example Output:
For the input string "banana", the program generates the following arrays:
Suffix Array: [5, 3, 1, 0, 4, 2] (indicating the starting indices of the lexicographically sorted suffixes)
LCP Array: [0, 1, 3, 0, 0, 2] (showing the lengths of the longest common prefixes between consecutive suffixes)
Why Suffix Arrays and LCP Arrays Matter:
Text Searching: Suffix arrays are used in algorithms for fast substring searching, making them invaluable in tasks like searching through large databases or text files.
Repetitive Patterns: The LCP array highlights repeated patterns within the text, which can be useful in applications like data compression, where redundancy needs to be minimized.
Bioinformatics: These arrays are critical for genome sequencing and alignment algorithms, where comparing large sequences efficiently is necessary.
How to Use:
This implementation is easy to run with any input string, and users can quickly get a clear visualization of the suffix and LCP arrays. Whether you're new to algorithms or looking to expand your toolkit for more advanced string manipulation tasks, this project provides a solid foundation.
2024-10-19 12:05:59 +05:30
Maxim Smolskiy
e3fa014a5a
Fix ruff ( #11527 )
...
* updating DIRECTORY.md
* Fix ruff
* Fix
* Fix
* Fix
* Revert "Fix"
This reverts commit 5bc3bf3422
.
* find_max.py: noqa: PLR1730
---------
Co-authored-by: MaximSmolskiy <MaximSmolskiy@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2024-08-25 17:33:11 +02:00
Pedram_Mohajer
70bd06db46
add doctest/document to actual_power and document to power ( #11187 )
...
* Update power.py
* Update divide_and_conquer/power.py
---------
Co-authored-by: Tianyi Zheng <tianyizheng02@gmail.com>
2024-06-01 02:09:03 -07:00
Maxim Smolskiy
516a3028d1
Enable ruff PLR5501 rule ( #11332 )
...
* Enable ruff PLR5501 rule
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-03-28 18:25:41 +01:00
pre-commit-ci[bot]
bc8df6de31
[pre-commit.ci] pre-commit autoupdate ( #11322 )
...
* [pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/astral-sh/ruff-pre-commit: v0.2.2 → v0.3.2](https://github.com/astral-sh/ruff-pre-commit/compare/v0.2.2...v0.3.2 )
- [github.com/pre-commit/mirrors-mypy: v1.8.0 → v1.9.0](https://github.com/pre-commit/mirrors-mypy/compare/v1.8.0...v1.9.0 )
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-03-13 07:52:41 +01:00
Saahil Mahato
678e0aa8cf
Mention square matrices in strassen docs and make it more clear ( #9839 )
...
* refactor: fix strassen matrix multiplication docs
* refactor: make docs more clear
2023-10-07 05:35:23 -04:00
pre-commit-ci[bot]
421ace81ed
[pre-commit.ci] pre-commit autoupdate ( #9013 )
...
* [pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/astral-sh/ruff-pre-commit: v0.0.285 → v0.0.286](https://github.com/astral-sh/ruff-pre-commit/compare/v0.0.285...v0.0.286 )
- [github.com/tox-dev/pyproject-fmt: 0.13.1 → 1.1.0](https://github.com/tox-dev/pyproject-fmt/compare/0.13.1...1.1.0 )
* updating DIRECTORY.md
* Fis ruff rules PIE808,PLR1714
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2023-08-29 15:18:10 +02:00
Caeden Perelli-Harris
93fb169627
[Upgrade Ruff] Fix all errors raised from ruff ( #8879 )
...
* chore: Fix tests
* chore: Fix failing ruff
* chore: Fix ruff errors
* chore: Fix ruff errors
* chore: Fix ruff errors
* chore: Fix ruff errors
* chore: Fix ruff errors
* chore: Fix ruff errors
* chore: Fix ruff errors
* chore: Fix ruff errors
* chore: Fix ruff errors
* chore: Fix ruff errors
* chore: Fix ruff errors
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* chore: Fix ruff errors
* chore: Fix ruff errors
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Update cellular_automata/game_of_life.py
Co-authored-by: Christian Clauss <cclauss@me.com>
* chore: Update ruff version in pre-commit
* chore: Fix ruff errors
* Update edmonds_karp_multiple_source_and_sink.py
* Update factorial.py
* Update primelib.py
* Update min_cost_string_conversion.py
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2023-07-22 12:05:10 +02:00
Tianyi Zheng
a0eec90466
Consolidate duplicate implementations of max subarray ( #8849 )
...
* Remove max subarray sum duplicate implementations
* updating DIRECTORY.md
* Rename max_sum_contiguous_subsequence.py
* Fix typo in dynamic_programming/max_subarray_sum.py
* Remove duplicate divide and conquer max subarray
* updating DIRECTORY.md
---------
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2023-07-11 11:44:12 +02:00
Tianyi Zheng
c93659d7ce
Fix type error in strassen_matrix_multiplication.py
( #8784 )
...
* Fix type error in strassen_matrix_multiplication.py
* updating DIRECTORY.md
---------
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2023-05-30 12:37:54 +12:00
Christian Clauss
4b79d771cd
Add more ruff rules ( #8767 )
...
* Add more ruff rules
* Add more ruff rules
* pre-commit: Update ruff v0.0.269 -> v0.0.270
* Apply suggestions from code review
* Fix doctest
* Fix doctest (ignore whitespace)
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
---------
Co-authored-by: Dhruv Manilawala <dhruvmanila@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2023-05-26 09:34:17 +02:00
Caeden Perelli-Harris
1faf10b5c2
Correct ruff failures ( #8732 )
...
* fix: Correct ruff problems
* updating DIRECTORY.md
* fix: Fix pre-commit errors
* updating DIRECTORY.md
---------
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2023-05-14 22:03:13 +01:00
Tianyi Zheng
cc10b20beb
Remove some print statements within algorithmic functions ( #7499 )
...
* Remove commented-out print statements in algorithmic functions
* Encapsulate non-algorithmic code in __main__
* Remove unused print_matrix function
* Remove print statement in __init__
* Remove print statement from doctest
* Encapsulate non-algorithmic code in __main__
* Modify algorithm to return instead of print
* Encapsulate non-algorithmic code in __main__
* Refactor data_safety_checker to return instead of print
* updating DIRECTORY.md
* updating DIRECTORY.md
* Apply suggestions from code review
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2022-10-22 13:33:51 +02:00
Caeden
4d0c830d2c
Add flake8 pluin flake8 bugbear to pre-commit ( #7132 )
...
* ci(pre-commit): Add ``flake8-builtins`` additional dependency to ``pre-commit`` (#7104 )
* refactor: Fix ``flake8-builtins`` (#7104 )
* fix(lru_cache): Fix naming conventions in docstrings (#7104 )
* ci(pre-commit): Order additional dependencies alphabetically (#7104 )
* fix(lfu_cache): Correct function name in docstring (#7104 )
* Update strings/snake_case_to_camel_pascal_case.py
Co-authored-by: Christian Clauss <cclauss@me.com>
* Update data_structures/stacks/next_greater_element.py
Co-authored-by: Christian Clauss <cclauss@me.com>
* Update digital_image_processing/index_calculation.py
Co-authored-by: Christian Clauss <cclauss@me.com>
* Update graphs/prim.py
Co-authored-by: Christian Clauss <cclauss@me.com>
* Update hashes/djb2.py
Co-authored-by: Christian Clauss <cclauss@me.com>
* refactor: Rename `_builtin` to `builtin_` ( #7104 )
* fix: Rename all instances (#7104 )
* refactor: Update variable names (#7104 )
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* ci: Create ``tox.ini`` and ignore ``A003`` (#7123 )
* revert: Remove function name changes (#7104 )
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Rename tox.ini to .flake8
* Update data_structures/heap/heap.py
Co-authored-by: Dhruv Manilawala <dhruvmanila@gmail.com>
* refactor: Rename `next_` to `next_item` (#7104 )
* ci(pre-commit): Add `flake8` plugin `flake8-bugbear` (#7127 )
* refactor: Follow `flake8-bugbear` plugin (#7127 )
* fix: Correct `knapsack` code (#7127 )
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Dhruv Manilawala <dhruvmanila@gmail.com>
2022-10-13 18:03:06 +02:00
Caeden
07e991d553
Add pep8-naming to pre-commit hooks and fixes incorrect naming conventions ( #7062 )
...
* ci(pre-commit): Add pep8-naming to `pre-commit` hooks (#7038 )
* refactor: Fix naming conventions (#7038 )
* Update arithmetic_analysis/lu_decomposition.py
Co-authored-by: Christian Clauss <cclauss@me.com>
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* refactor(lu_decomposition): Replace `NDArray` with `ArrayLike` (#7038 )
* chore: Fix naming conventions in doctests (#7038 )
* fix: Temporarily disable project euler problem 104 (#7069 )
* chore: Fix naming conventions in doctests (#7038 )
Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2022-10-13 00:54:20 +02:00
Christian Clauss
b75a7c77f8
pre-commit autoupdate: pyupgrade v2.34.0 -> v2.37.0 ( #6245 )
...
* pre-commit autoupdate: pyupgrade v2.34.0 -> v2.37.0
* pre-commit run --all-files
2022-07-11 10:19:52 +02:00
Omkaar
dbee5f072f
Improve code on f-strings and brevity ( #6126 )
...
* Update strassen_matrix_multiplication.py
* Update matrix_operation.py
* Update enigma_machine2.py
* Update enigma_machine.py
* Update enigma_machine2.py
* Update rod_cutting.py
* Update external_sort.py
* Update sol1.py
* Update hill_cipher.py
* Update prime_numbers.py
* Update integration_by_simpson_approx.py
2022-05-13 20:51:44 +08:00
Shuangchi He
e1ec661d4e
Fix some typos ( #6113 )
...
* Fix some typos.
* Update volume.py
Co-authored-by: John Law <johnlaw.po@gmail.com>
2022-05-01 18:44:23 +08:00
Muhammad Hammad Sani
e311b02e70
Remove unnecessary branch ( #4824 )
...
* Algorithm Optimized
* Update divide_and_conquer/inversions.py
Co-authored-by: John Law <johnlaw.po@gmail.com>
* Update divide_and_conquer/inversions.py
Co-authored-by: John Law <johnlaw.po@gmail.com>
* Update divide_and_conquer/inversions.py
Co-authored-by: John Law <johnlaw.po@gmail.com>
Co-authored-by: John Law <johnlaw.po@gmail.com>
2021-10-12 00:33:06 +08:00
Christian Clauss
cecf43d648
Pyupgrade to Python 3.9 ( #4718 )
...
* Pyupgrade to Python 3.9
* updating DIRECTORY.md
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2021-09-07 13:37:03 +02:00
algobytewise
959507901a
[mypy] fix small folders ( #4292 )
...
* add final else-statement
* fix file_transfer
* fix quantum folder
* fix divide_and_conquer-folder
* Update build.yml
* updating DIRECTORY.md
* Update ripple_adder_classic.py
* Update .github/workflows/build.yml
* removed imports from typing
* removed conversion to string
* Revert "removed conversion to string"
This reverts commit 2f7c4731d1
.
* implemented suggested changes
* Update receive_file.py
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2021-03-23 16:51:50 +01:00
Cho Yin Yong
287bf26bc8
Add a divide and conquer method in finding the maximum difference pair ( #3692 )
...
* A divide and conquer method in finding the maximum difference pair
* fix formatting issues
* fix formatting issues
* add doctest runner
2020-11-25 08:30:15 +08:00
Cho Yin Yong
eb5a951603
Peak of unimodal list DNC algorithm ( #3691 )
...
* Peak of unimodal list DNC algorithm
* fix black formatting issues
* add doctest testing
* make file black compliant
2020-11-11 19:17:54 +08:00
Cho Yin Yong
eaa7ef45c5
kth order statistic divide and conquer algorithm ( #3690 )
...
* kth order statistics divide and conquer algorithm
* add explanation of algorithm.
* fix PEP8 line too long error
* update order to be compliant to isort
* add doctest
* make file black compliant
2020-11-03 09:31:33 +08:00
Simon Lammer
e20895a4ff
Implement the melkman anlgorithm for computing convex hulls ( #2916 )
...
* Implement the melkman anlgorithm for computing convex hulls
* Link melkman algorithm description
* Format melkman algorithm code
* Add type hints to functions
* Fix build errors
2020-10-29 08:46:16 +08:00
Akash G Krishnan
de2725f4ac
Update mergesort.py ( #2563 )
...
* Update mergesort.py
1) Updating the merge sort in python as the previous implementation was modifying the input array
2) divided the division part and conquer part of the merge sort algorithm as 2 functions namely mergeSort and merge.
3) function mergeSort divides the function into halves i.e the purpose of the function will be to divide the array
4) function merge will merge 2 halves into a sorted array
5)Added random test cases using shuffle as suggested by @dhruvmanila
6 The time and space complexity of the previous and my version remains the same. i.e (n log(n) time and n log(n) space
7) changed variables as per the python case as required and suggested by @dhruvmanila
8) Updated function names as suggested by @dhurvmanila
* Update mergesort.py
Added in few more test cases
added type hints for the functions and parameters as suggested by @dhruvmanila
formatted the code using Auto Pep8
* Update mergesort.py
update and added new testcases
* Update mergesort.py
Added in doc test in merge function
* Update mergesort.py
fixing pre-commit fails
* Update mergesort.py
Co-authored-by: Dhruv <dhruvmanila@gmail.com>
2020-10-15 14:00:12 +05:30
Guillaume Rochedix
d95d643351
Heaps algorithm ( #2475 )
...
* heaps_algorithm: new algo
* typo
* correction doctest
* doctests: compare with itertools.permutations
* doctest: sorted instead of set
* doctest
* doctest
* rebuild
2020-09-29 12:39:07 +02:00
Guillaume Rochedix
04322e67e5
Heaps algorithm iterative ( #2505 )
...
* heap's algorithm iterative
* doctest
* doctest
* rebuild
2020-09-29 12:38:12 +02:00
Dhruv
48357cea5b
Add __init__.py files in all the directories ( #2503 )
2020-09-28 19:42:36 +02:00
Christian Clauss
9200a2e543
from __future__ import annotations ( #2464 )
...
* from __future__ import annotations
* fixup! from __future__ import annotations
* fixup! from __future__ import annotations
* fixup! Format Python code with psf/black push
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-09-23 13:30:13 +02:00
Du Yuanchao
4d0a8f2355
Optimized recursive_bubble_sort ( #2410 )
...
* optimized recursive_bubble_sort
* Fixed doctest error due whitespace
* reduce loop times for optimization
* fixup! Format Python code with psf/black push
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-09-10 10:31:26 +02:00
Christian Clauss
b9e5259aeb
Fix long line, tests ( #2123 )
...
* Fix long line
* updating DIRECTORY.md
* Add doctest
* ...
* ...
* Update tabu_search.py
* space
* Fix doctest
>>> find_neighborhood(['a','c','b','d','e','a']) # doctest: +NORMALIZE_WHITESPACE
[['a','e','b','d','c','a',90], [['a','c','d','b','e','a',90],
['a','d','b','c','e','a',93], ['a','c','b','e','d','a',102],
['a','c','e','d','b','a',113], ['a','b','c','d','e','a',93]]
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: John Law <johnlaw.po@gmail.com>
2020-06-16 14:29:13 +02:00
Christian Clauss
9316e7c014
Set the Python file maximum line length to 88 characters ( #2122 )
...
* flake8 --max-line-length=88
* fixup! Format Python code with psf/black push
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-06-16 10:09:19 +02:00
Ekansh Mangal
025b1a6989
Merge sort Update variable names ( #2032 )
...
* Update Merge sort variable names
* Update mergesort.py
* Update mergesort.py
* black
* Update mergesort.py
Co-authored-by: Christian Clauss <cclauss@me.com>
2020-05-24 08:38:43 +02:00
Christian Clauss
1f8a21d727
Tighten up psf/black and flake8 ( #2024 )
...
* Tighten up psf/black and flake8
* Fix some tests
* Fix some E741
* Fix some E741
* updating DIRECTORY.md
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-05-22 08:10:11 +02:00
Christian Clauss
6acd7fb5ce
Wrap lines that go beyond GitHub Editor ( #1925 )
...
* Wrap lines that go beyond GiHub Editor
* flake8 --count --select=E501 --max-line-length=127
* updating DIRECTORY.md
* Update strassen_matrix_multiplication.py
* fixup! Format Python code with psf/black push
* Update decision_tree.py
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-05-01 23:36:35 +02:00