Commit Graph

450 Commits

Author SHA1 Message Date
pre-commit-ci[bot]
e3f3d668be
[pre-commit.ci] pre-commit autoupdate (#12370)
* [pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/astral-sh/ruff-pre-commit: v0.7.2 → v0.7.3](https://github.com/astral-sh/ruff-pre-commit/compare/v0.7.2...v0.7.3)
- [github.com/abravalheri/validate-pyproject: v0.22 → v0.23](https://github.com/abravalheri/validate-pyproject/compare/v0.22...v0.23)

* Update sudoku_solver.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>
2024-11-11 21:05:50 +01:00
1227haran
cfd6d095f1
Added max_sum_bst.py (#11832)
* Added new algorithm

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Updated changes

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Updated filename

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Updated code

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Updated the code

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Updated code

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Updated the code

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Updated code

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Updated the code

* Updated code

* Updated code

* Updated code

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Updated the code

* Updated code

* Updated code

* Updated code

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Updated code

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Updated code

* updated

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Updated code

* Updated code

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Updated code

* Updated code

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Updated code

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Updated code

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Apply suggestions from code review

* Update maximum_sum_bst.py

* def max_sum_bst(root: TreeNode | None) -> int:

* def solver(node: TreeNode | None) -> tuple[bool, int, int, int]:

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2024-10-07 10:36:15 +02:00
1227haran
5a8655d306
Added new algorithm to generate numbers in lexicographical order (#11674)
* Added algorithm to generate numbers in lexicographical order

* Removed the test cases

* Updated camelcase to snakecase

* Added doctest

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Added descriptive name for n

* Reduced the number of letters

* Updated the return type

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Updated import statement

* Updated return type to Iterator[int]

* removed parentheses

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-10-05 10:19:58 -07:00
JeevaRamanathan
40f65e8150
Improve comments, docstrings in next_greatest_element.py (#11685)
* Improve comments in next_greatest_element.py

Signed-off-by: JeevaRamanathan <jeevaramanathan.m@infosys.com>

* few changes

Signed-off-by: JeevaRamanathan <jeevaramanathan.m@infosys.com>

* updated descriptions of the functions parameters

Signed-off-by: JeevaRamanathan <jeevaramanathan.m@infosys.com>

---------

Signed-off-by: JeevaRamanathan <jeevaramanathan.m@infosys.com>
2024-10-02 17:18:01 -07:00
1227haran
918fa8bb8a
Optimized O(n) to O(1) (#11669) 2024-10-02 11:07:07 -07:00
Hardik Pawar
00e9d86224
Improve comments, add doctests in symmetric_tree.py (#11619) 2024-10-01 19:54:12 -07:00
Christian Clauss
0177ae1cd5
Upgrade to Python 3.13 (#11588) 2024-09-30 23:01:15 +02:00
Ramy
976e385c1d
Implemented Suffix Tree Data Structure (#11554)
* Implemented KD-Tree Data Structure

* Implemented KD-Tree Data Structure. updated DIRECTORY.md.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Create __init__.py

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Replaced legacy `np.random.rand` call with `np.random.Generator` in kd_tree/example_usage.py

* Replaced legacy `np.random.rand` call with `np.random.Generator` in kd_tree/hypercube_points.py

* added typehints and docstrings

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* docstring for search()

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Added tests. Updated docstrings/typehints

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* updated tests and used | for type annotations

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* E501 for build_kdtree.py, hypercube_points.py, nearest_neighbour_search.py

* I001 for example_usage.py and test_kdtree.py

* I001 for example_usage.py and test_kdtree.py

* Update data_structures/kd_tree/build_kdtree.py

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update data_structures/kd_tree/example/hypercube_points.py

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update data_structures/kd_tree/example/hypercube_points.py

Co-authored-by: Christian Clauss <cclauss@me.com>

* Added new test cases requested in Review. Refactored the test_build_kdtree() to include various checks.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Considered ruff errors

* Considered ruff errors

* Apply suggestions from code review

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update kd_node.py

* imported annotations from __future__

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Implementation of the suffix tree data structure

* Adding data to DIRECTORY.md

* Minor file renaming

* minor correction

* renaming in DIRECTORY.md

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Considering ruff part-1

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Considering ruff part-2

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Considering ruff part-3

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Considering ruff part-4

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Considering ruff part-5

* Implemented Suffix Tree Data Structure.
Added some comments to my files in #11532, #11554.

* updating DIRECTORY.md

* Implemented Suffix Tree Data Structure.
Added some comments to my files in #11532, #11554.

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: Ramy-Badr-Ahmed <Ramy-Badr-Ahmed@users.noreply.github.com>
2024-09-28 15:37:00 +02:00
Ramy
f16d38f26f
kd tree data structure implementation (#11532)
* Implemented KD-Tree Data Structure

* Implemented KD-Tree Data Structure. updated DIRECTORY.md.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Create __init__.py

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Replaced legacy `np.random.rand` call with `np.random.Generator` in kd_tree/example_usage.py

* Replaced legacy `np.random.rand` call with `np.random.Generator` in kd_tree/hypercube_points.py

* added typehints and docstrings

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* docstring for search()

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Added tests. Updated docstrings/typehints

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* updated tests and used | for type annotations

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* E501 for build_kdtree.py, hypercube_points.py, nearest_neighbour_search.py

* I001 for example_usage.py and test_kdtree.py

* I001 for example_usage.py and test_kdtree.py

* Update data_structures/kd_tree/build_kdtree.py

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update data_structures/kd_tree/example/hypercube_points.py

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update data_structures/kd_tree/example/hypercube_points.py

Co-authored-by: Christian Clauss <cclauss@me.com>

* Added new test cases requested in Review. Refactored the test_build_kdtree() to include various checks.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Considered ruff errors

* Considered ruff errors

* Apply suggestions from code review

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update kd_node.py

* imported annotations from __future__

* [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>
Co-authored-by: Christian Clauss <cclauss@me.com>
2024-09-03 14:39:09 +02:00
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
pre-commit-ci[bot]
716bdeb68b
[pre-commit.ci] pre-commit autoupdate (#11473)
* [pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/astral-sh/ruff-pre-commit: v0.4.10 → v0.5.0](https://github.com/astral-sh/ruff-pre-commit/compare/v0.4.10...v0.5.0)
- [github.com/pre-commit/mirrors-mypy: v1.10.0 → v1.10.1](https://github.com/pre-commit/mirrors-mypy/compare/v1.10.0...v1.10.1)

* Fix ruff issues

* Fix ruff issues

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2024-07-02 07:02:29 +02:00
Marco-campione-github
b8afb214f8
Changed the N to self.N in show_data in segment_tree.py (#11276) 2024-05-31 01:11:09 -07:00
Maxim Smolskiy
c599f6c910
Fix some SIM114 per file ignores (#11395)
* updating DIRECTORY.md

* Fix some SIM114 per file ignores

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Fix review issue

---------

Co-authored-by: MaximSmolskiy <MaximSmolskiy@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-05-10 21:59:53 +02:00
Maxim Smolskiy
5131e3145d
Fix some ARG002 per file ignores (#11382)
* Fix some ARG002 per file ignores

* Fix

* updating DIRECTORY.md

* Fix review issue

* Fix review issue

---------

Co-authored-by: MaximSmolskiy <MaximSmolskiy@users.noreply.github.com>
2024-05-01 21:27:59 +02:00
Maxim Smolskiy
2d6be5fbb0
Enable ruff UP031 rule (#11388) 2024-04-30 06:40:26 +02:00
Maxim Smolskiy
4700297b3e
Enable ruff RUF002 rule (#11377)
* Enable ruff RUF002 rule

* Fix

---------

Co-authored-by: Christian Clauss <cclauss@me.com>
2024-04-22 21:51:47 +02:00
Maxim Smolskiy
7b88e15b1c
Enable ruff RUF007 rule (#11349)
* Enable ruff RUF005 rule

* Enable ruff RUF007 rule

* Fix

* Fix

* Fix

* Update sorts/bead_sort.py

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update sorts/bead_sort.py

* Revert "Update sorts/bead_sort.py"

This reverts commit b10e5632e4.

* Revert "Update sorts/bead_sort.py"

This reverts commit 2c1816bf10.

* Update sorts/bead_sort.py

---------

Co-authored-by: Christian Clauss <cclauss@me.com>
2024-04-20 16:20:27 +02:00
Maxim Smolskiy
a42eb35702
Enable ruff E741 rule (#11370)
* Enable ruff E741 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-04-19 21:30:22 +02:00
Jiayou Qin
9e55c9d984
Added documentations (#11352)
* Added documentations

* Update data_structures/queue/circular_queue.py

---------

Co-authored-by: Christian Clauss <cclauss@me.com>
2024-04-08 13:35:22 +02:00
Maxim Smolskiy
53b2926704
Enable ruff PGH003 rule (#11345)
* Enable ruff PGH003 rule

* Fix

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Fix

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-04-02 21:29:34 +02:00
Maxim Smolskiy
f5bbea3776
Enable ruff RUF005 rule (#11344) 2024-04-02 21:18:47 +02:00
Maxim Smolskiy
f437f92279
Enable ruff INP001 rule (#11346)
* Enable ruff INP001 rule

* Fix

* Fix

* Fix

* Fix

* Fix
2024-04-02 21:13:56 +02:00
Maxim Smolskiy
93fb555e0a
Enable ruff SIM102 rule (#11341)
* Enable ruff SIM102 rule

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Fix

* [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-04-02 03:27:56 +02:00
Maxim Smolskiy
39daaf8248
Enable ruff RUF100 rule (#11337) 2024-04-01 21:36:41 +02: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
MrBubb1es
19fd435042
Improved doctests for some functions (#11334) 2024-03-28 18:19:51 +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
pre-commit-ci[bot]
ed8d9209da
[pre-commit.ci] pre-commit autoupdate (#11275)
* [pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/astral-sh/ruff-pre-commit: v0.1.14 → v0.2.0](https://github.com/astral-sh/ruff-pre-commit/compare/v0.1.14...v0.2.0)

* Upgrade pyproject.toml

* Revert sudoku_solver.py RUF017 Avoid quadratic list summation

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2024-02-05 20:48:10 +01:00
Suyash Dongre
05a5cdacc3
Added doctest to skew_heap.py (#11147)
* Added doctest to skew_heap.py

* Update skew_heap.py

* Update data_structures/heap/skew_heap.py

Co-authored-by: Saptadeep Banerjee  <69459134+imSanko@users.noreply.github.com>

* Update skew_heap.py

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update skew_heap.py

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: Saptadeep Banerjee <69459134+imSanko@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-01-18 13:39:27 +01:00
Ataf Fazledin Ahamed
0101dd42dc
Fixed Inappropriate Logical Expression (#11203)
Signed-off-by: fazledyn-or <ataf@openrefactory.com>
2024-01-16 09:43:33 +01:00
Indrajeet Mishra
b46fc1de04
Corrected the Python Doctest command in equilibrium_index_in_array.py script (#11212)
Co-authored-by: Indrajeet Mishra <indrajeetmishra@thecoddiwompler.local>
2023-12-20 00:05:27 +01:00
Suyash Dongre
84a1533fd5
Added doctest to binary_search_tree.py (#11145)
* Added doctest to binary_search_tree.py

* Apply suggestions from code review

---------

Co-authored-by: Christian Clauss <cclauss@me.com>
2023-11-25 15:29:44 +01:00
Suyash Dongre
0e2e6abd6f
Added doctest to heap.py (#11129)
* Added doctest to heap.py

* Update heap.py
2023-11-13 17:05:22 +06:00
Suyash Dongre
fb17eeab7d
Added doctest to stack.py (#11149) 2023-11-11 21:16:43 -05:00
Suyash Dongre
8b7352626e
Added doctest to randomized_heap.py (#11151) 2023-11-11 21:13:04 -05:00
Sunny Kumar
eb989c08cd
Data structures/arrays/triplet sum (#11134)
* updated code for find triplets with 0 sum

Signed-off-by: Skyad <777.sunnykumar@gmail.com>

* extra line added at the end of file

Signed-off-by: Sunny Kumar <sunny.kumar09@ad.infosys.com>

* extra line added at the end of file

Signed-off-by: Skyad <777.sunnykumar@gmail.com>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* file updated with comments

Signed-off-by: Skyad <777.sunnykumar@gmail.com>

* updated the comments as suggested by community

Signed-off-by: Sunny Kumar <sunny.kumar09@ad.infosys.com>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* file updated according to community comments

Signed-off-by: Skyad <777.sunnykumar@gmail.com>

* Update find_triplets_with_0_sum.py

---------

Signed-off-by: Skyad <777.sunnykumar@gmail.com>
Signed-off-by: Sunny Kumar <sunny.kumar09@ad.infosys.com>
Co-authored-by: Sunny Kumar <sunny.kumar09@ad.infosys.com>
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-11-06 18:10:50 +06:00
Suyash Dongre
1e50cf3660
Added doctest to binary_search_tree.py (#11141)
* Added doctest to binary_search_tree.py

* Update binary_search_tree.py

* Update binary_search_tree.py

---------

Co-authored-by: Christian Clauss <cclauss@me.com>
2023-11-05 14:23:39 +05:45
Suyash Dongre
ebfdb127e7
Added doctest to hash_map.py (#11105)
* Added doctest to heap.py

* Added doctest to hash_map.py

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update hash_map.py

* Added doctest to hash_map.py

* Added doctest to hash_map.py

* Added doctest to detecting_english_programmatically.py

* Update detecting_english_programmatically.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-11-04 17:49:57 +05:45
dekomori_sanae09
c38b222212
serialize deserialize binary tree (#9625)
* added serialize and desrialize bin tree

* format files

* added type hints

* added type hints

* Use dataclass .__eq__(), .__iter__(), and .__repr__()

---------

Co-authored-by: Christian Clauss <cclauss@me.com>
2023-10-30 00:07:21 +01:00
Suyash Dongre
67c85ee289
Added doctest to hash_map.py (#11082)
* Added doctest to heap.py

* Added doctest to hash_map.py

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update hash_map.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-10-29 17:01:54 +01:00
Suyash Dongre
b51b833e0a
Added doctest to heap.py (#11059) 2023-10-28 21:43:20 +02:00
Khushi Shukla
185a35589a
Create monotonic_array.py (#11025)
* Create monotonic_array.py

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update monotonic_array.py

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2023-10-27 12:42:34 -04:00
Suyash Dongre
f336cca8f8
Added doctest to double_hash.py (#11020)
* Added doctest to double_hash.py

* Update double_hash.py
2023-10-27 12:40:42 -04:00
Suyash Dongre
34eb9c529a
Added doctest to hash_table.py (#11023)
* Added doctest to hash_table.py

* Update hash_table.py

* Update hash_table.py

* Update hash_table.py

* Update hash_table.py

* Apply suggestions from code review

* Update hash_table.py

---------

Co-authored-by: Christian Clauss <cclauss@me.com>
2023-10-27 14:36:43 +02:00
Suyash Dongre
fe4aad0ec9
Added doctest & docstring to quadratic_probing.py (#10996)
* Added doctest & docstring to quadratic_probing.py

* Update quadratic_probing.py

* Update quadratic_probing.py
2023-10-26 17:21:45 +02:00
Ed
a8dfd403f6
Add new algorithm index_2d_array_in_1d (#10973)
* Add new algorithm index_2d_array_in_1d

* Add doctest for iter function

* The power of dataclasses

* Update index_2d_array_in_1d.py

---------

Co-authored-by: Christian Clauss <cclauss@me.com>
2023-10-26 16:33:42 +02:00
Suyash Dongre
29b8ccdc2f
Added doctest to hash_table.py (#10984) 2023-10-26 14:12:28 +02:00
Neha
6497917352
Added Kth largest element algorithm (#10687)
* neha3423

* neha3423

* neha3423

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* neha3423

* neha3423

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* neha323

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* neha3423

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* neha3423

* neha3423

* neha3423

* neha3423

* Added test case for tuple

* Update kth_largest_element.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-10-26 10:54:30 +02:00
AdityaAtoZ
3d0a409ce1
Improved Equilibrium Index of an Array. (#10899)
* Improved Equilibrium Index of an Array.

This is the modifications made to the original code:

1. Create Doctest Instructions: Python "doctest" can be executed by running the following command: python -m doctest -v equilibrium_index.py.

2. Deleted Argument {size}: Deleted the `size` argument because `len(arr)} allows the array's length to be determined inside the function, simplifying and improving the readability of the function signature.

3. Used {enumerate}: To improve code readability and indicate that we're working with element-index pairs, we iterated through the array using both elements and their indices using the `enumerate` function.

4. Optimized the Loop: To prevent pointless additions, the loop was improved by initializing {left_sum} with the value of the first element (arr[0]). Furthermore, since the beginning and last items (0 and size - 1) cannot be equilibrium indices, there is no need to check them, saving further computations.

* [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>
2023-10-25 16:33:35 -04:00
Christian Clauss
c2c6cb0f5c
Add dataclasses to binary_search_tree.py (#10920) 2023-10-25 16:28:23 -04:00