Commit Graph

365 Commits

Author SHA1 Message Date
Jogendra Singh
5d02103b27
Fixed #4764 (#4779)
* Fixed #4764

* Fixes #4764
2021-09-24 12:54:38 +02: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
Aniruddha Bhattacharjee
b743e44259
Wavelet tree (#4267)
* Added the matrix_exponentiation.py file in maths directory

* Implemented the requested changes

* Update matrix_exponentiation.py

* resolve merge conflict with upstream branch

* add new line at end of file

* add wavelet_tree

* fix isort issue

* updating DIRECTORY.md

* fix variable names in wavelet_tree and correct typo

* Add type hints and variable renaming

* Update data_structures/binary_tree/wavelet_tree.py

Add doctests to placate the algorithm-bot, thanks to @cclauss.

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

* Move doctest to individual functions and reformat code

* Move common test array to the global scope and reuse in tests

* MMove test array to global scope and minor linting changes

* Correct the failing pytest tests

* MUse built-in list for type annotation

* Update wavelet_tree.py

* types-requests

* updating DIRECTORY.md

* Update wavelet_tree.py

* # type: ignore

* # type: ignore

* Update decrypt_caesar_with_chi_squared.py

* ,

* Update decrypt_caesar_with_chi_squared.py

Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: Aniruddha Bhattacharjee <aniruddha@Aniruddhas-MacBook-Air.local>
2021-06-08 22:49:33 +02:00
Ahmed Haj Abdel Khaleq
deb71167e7
[mypy] Fix type annotations for linked_stack.py, evaluate_postfix_notations.py, stack.py in data structures (#4409)
* [mypy] Fix type annotations for linked_stack.py, next_greater_element.py, stack.py

* Reformatted files according to black
2021-05-12 08:22:42 +02:00
Dhruv Manilawala
6f21f76696
fix(ci): Update pre-commit hooks and apply new black (#4359)
* fix(ci): Update pre-commit hooks and apply new black

* remove empty docstring
2021-04-26 07:46:50 +02:00
Christian Clauss
69457357e8
binary_tree_traversals.py: Simplify with dataclasses (#4336)
* binary_tree_traversals.py: Simplify with dataclasses

* Update data_structures/binary_tree/binary_tree_traversals.py

Co-authored-by: Dhruv Manilawala <dhruvmanila@gmail.com>

* Optional["Node"]

Co-authored-by: Dhruv Manilawala <dhruvmanila@gmail.com>
2021-04-26 10:15:26 +05:30
CarsonHam
61f3119467
Change occurrences of str.format to f-strings (#4118)
* f-string update rsa_cipher.py

* f-string update rsa_key_generator.py

* f-string update burrows_wheeler.py

* f-string update non_recursive_segment_tree.py

* f-string update red_black_tree.py

* f-string update deque_doubly.py

* f-string update climbing_stairs.py

* f-string update iterating_through_submasks.py

* f-string update knn_sklearn.py

* f-string update 3n_plus_1.py

* f-string update quadratic_equations_complex_numbers.py

* f-string update nth_fibonacci_using_matrix_exponentiation.py

* f-string update sherman_morrison.py

* f-string update levenshtein_distance.py

* fix lines that were too long
2021-02-23 11:23:49 +05:30
Hao LI
f680806894
add type hints for avl_tree (#4214)
Co-authored-by: LiHao <leo_how@163.com>
2021-02-22 00:58:17 +01:00
Hao LI
2595cf059d
[mypy] Add/fix type annotations for binary trees in data structures (#4085)
* fix mypy: data_structures:binary_tree

* mypy --strict for binary_trees in data_structures

* fix pre-commit

Co-authored-by: LiHao <leo_how@163.com>
2021-02-05 00:59:38 +08:00
Gaurav Jindal
0728cf1128
Added code to merge two trees (#4121)
* Added code to merge two trees

* Added doctest and type hints

* Added pre-commit
2021-01-18 13:08:22 +05:30
Mark Huang
207ac957ef
[mypy] Add type hints and docstrings to heap.py (#3013)
* Add type hints and docstrings to heap.py

- Add type hints
- Add docstrings
- Add explanatory comments 
- Improve code readability
- Change to use f-string

* Fix import sorting

* fixup! Format Python code with psf/black push

* Fix static type error

* Fix failing test

* Fix type hints

* Add return annotation

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: Dhruv Manilawala <dhruvmanila@gmail.com>
2020-12-26 08:42:37 +05:30
Maliha
860d4f547b
Create merge_two_lists.py that implements merging of two sorted linked lists (#3874)
* Create merge_two_lists.py that implements merging of two sorted linked lists

* Update merge_two_lists.py

Fixed formatting errors

* Fixed trailing whitespace

* Change name of function to def __str__()

* updating DIRECTORY.md

* Imported classes from singly_linked_list.py

* Update merge_two_lists.py

* Update merge_two_lists.py

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2020-12-03 16:02:48 +01:00
arif599
9c6080a6fc
data_structures/linked_list: Add __str__() function (#3961)
* Adding __str__() function

* Removing white space

* Update data_structures/linked_list/__init__.py

Co-authored-by: xcodz-dot <71920621+xcodz-dot@users.noreply.github.com>

* Adding type hints

* Update __init__.py

* Update __init__.py

* Adding the changes requested

* Updating to fix pre-commit

* Updating __init__.py

* Updating __init__.py

Co-authored-by: xcodz-dot <71920621+xcodz-dot@users.noreply.github.com>
2020-11-28 11:20:18 +05:30
Du Yuanchao
786b32431c
Update infix to postfix (#3817)
* add test to infix_to_postfix_conversion

* fixed pre-commit error

* fixed build error

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-11-02 00:35:31 +08:00
Du Yuanchao
a03b3f763f
Balanced parentheses (#3768)
* Fixed balanced_parentheses.py

* fixed pre-commit

* eliminate is_paired

* remove unused line

* updating DIRECTORY.md

* Update data_structures/stacks/balanced_parentheses.py

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

* Add more test cases

* Update data_structures/stacks/balanced_parentheses.py

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

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2020-10-29 10:39:19 +01:00
Du Yuanchao
1cd8e68537
Update LinkedQueue (#3683)
* update LinkedQueue

* add type hint and rename
2020-10-24 12:16:37 +02:00
Du Yuanchao
c2b7acdf11
Update Linked Stack (#3625)
* update linked_stack

* remove properties

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-10-24 00:16:23 +08:00
Du Yuanchao
5e642607c8
Update doubly linked list (#3619)
* update doubly linked list

* reformat code
add more test

* add test to iter

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-10-21 22:31:09 +08:00
Christian Clauss
9b95e4f662
Pyupgrade to python3.8 (#3616)
* Upgrade to Python 3.8 syntax

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-10-21 12:46:14 +02:00
Akash G Krishnan
7d84f7fe61
Adding in the evaluate postfix notation using Stack (#2598)
* Create evaluate_postfix_notations.py

Adding in the evaluate postfix notation using Stacks
one of the common use with simple stack question
creating a new file for the data structure of stacks

* Create evaluate_postfix_notations.py

Adding in the evaluate postfix notation using Stacks
one of the common use with simple stack question
creating a new file for the data structure of stacks

* Delete evaluate_postfix_notations.py

* Evaluate postfix expression stack clean approach

Sending in the PR again as the Previous request failed in pre commit

* Update evaluate_postfix_notations.py

* Update evaluate_postfix_notations.py

Made changes as per the required for fixing the failing pre-commits.

* Update evaluate_postfix_notations.py

Made changes as suggested by @cclauss

* Update evaluate_postfix_notations.py

fixed pre-commit fails

* Update evaluate_postfix_notations.py

fixing pre-commit fails

* Update evaluate_postfix_notations.py

Deleted trailing white spaces causing pre-commits to fail

* Update data_structures/stacks/evaluate_postfix_notations.py

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

* Update data_structures/stacks/evaluate_postfix_notations.py

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

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-10-16 20:45:26 +02:00
Akash G Krishnan
c33b683193
New doubly linkedlist PR: pull/2573 (#3380)
https://github.com/TheAlgorithms/Python/pull/2573 
the second implementation of the Doubly linked list
2020-10-16 15:13:45 +02:00
Anshraj Shrivastava
e035c6164f
add binary_tree_traversals.py to data_structures (#3297)
* add binary_tree_traversals.py to data_structures

I have added some interesting binary tree traversing methods.

* Fixed error

* Update data_structures/binary_tree/binary_tree_traversals.py

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

* Update binary_tree_traversals.py

* Update binary_tree_traversals.py

* Update binary_tree_traversals.py

* Update data_structures/binary_tree/binary_tree_traversals.py

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

* Update binary_tree_traversals.py

* Update binary_tree_traversals.py

* Update binary_tree_traversals.py

* Update binary_tree_traversals.py

* Update binary_tree_traversals.py

* Update binary_tree_traversals.py

* Update binary_tree_traversals.py

* Update binary_tree_traversals.py

* Update binary_tree_traversals.py

* Update binary_tree_traversals.py

* Update data_structures/binary_tree/binary_tree_traversals.py

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

* Update binary_tree_traversals.py

* Update binary_tree_traversals.py

* Update data_structures/binary_tree/binary_tree_traversals.py

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

* Update data_structures/binary_tree/binary_tree_traversals.py

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

* Update binary_tree_traversals.py

* Update data_structures/binary_tree/binary_tree_traversals.py

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

* Update binary_tree_traversals.py

* Doctests and type hints

* Add spaces

* Update binary_tree_traversals.py

* black exclude data_structures/binary_tree/binary_tree_traversals.py

* Add spaces again

* Update binary_tree_traversals.py

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-10-15 13:09:59 +02:00
Phil Bazun
e3c07f987f
Add skew heap data structure. (#3238)
* Add skew heap data structure.

* fixup! Add skew heap data structure.

* fixup! Add skew heap data structure.

* fixup! Add skew heap data structure.

* Add tests.

* Add __iter__ method.

* fixup! Add __iter__ method.
2020-10-14 12:35:53 +02:00
Susmith98
dc069580b9
Added binary tree mirror algorithm (#3159)
* Added binary tree mirror algorithm

* Minor changes

* Resolved comments

* Minor Changes

* resolved comments and updated doctests

* updated doctests

* updating DIRECTORY.md

Co-authored-by: svedire <VedireSusmith_Reddy@intuit.com>
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-10-14 12:21:15 +02:00
Phil Bazun
f0aa63f0f9
Add randomized heap. (#3241) 2020-10-14 12:17:02 +02:00
Sherman Hui
477b2c24b8
Hacktoberfest: Update Linked List - print_reverse method (#2792)
* chore: update print_reverse helper method

Use a generator expression instead of slicing
`elements_list` to improve the space and time complexity
of `make_linked_list` to O(1) space and O(n) time
by avoiding the creation a shallow copy of `elements_list`.

* fix: add type checking and argument typing

Add argument typing to all methods in `print_reverse`

Add doctest to helper function `make_linked_list` and
basic edge case tests to `print_reverse`

* test: add `print_reverse` test

Fix doctest syntax and remove edge case tests that are covered
by typed arguments.

Add `print_reverse` test that expects the correct values are printed
out by adding a `test_print_reverse_output` helper function.

* format code

Co-authored-by: shellhub <shellhub.me@gmail.com>
2020-10-05 19:08:57 +08:00
Dhruv
9016fe192f
Fix imports for all namespace packages (#2506)
* Fix imports as they're namespace packages

* Fix import for scripts/validate_filenames.py

* Fix path in doctest
2020-09-28 23:41:04 +02:00
Dhruv
48357cea5b
Add __init__.py files in all the directories (#2503) 2020-09-28 19:42:36 +02:00
Du Yuanchao
7f48bb8c95
Updated circular_linked_list (#2483)
* Updated circular_linked_list

* fixup! Format Python code with psf/black push

* Update data_structures/linked_list/circular_linked_list.py

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

* updating DIRECTORY.md

* delete print_list()

* test is_empty()

* test is_empty return False

* fixup! Format Python code with psf/black push

* fixed indentation

* fixup! Format Python code with psf/black push

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2020-09-26 22:57:09 +08:00
Du Yuanchao
b81fcef66b
Fixed linked list bug (#2481)
* * fixed __getitem__() function
* add test

* * updated doctests
* updated __setitem__() func

* fixup! Format Python code with psf/black push

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-09-25 18:08:57 +02:00
Du Yuanchao
18f1dcd48a
Updated singly_linked_list (#2477)
* Updated singly_linked_list

* fixup! Format Python code with psf/black push

* undo __repr__

* updating DIRECTORY.md

* UNTESTED CHANGES: Add an .__iter__() method.

This will break tests, etc.

* fixup! Format Python code with psf/black push

* len(tuple(iter(self)))

* fixed __repr__()

* Update data_structures/linked_list/singly_linked_list.py

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

* Update data_structures/linked_list/singly_linked_list.py

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

* Update data_structures/linked_list/singly_linked_list.py

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

* Update data_structures/linked_list/singly_linked_list.py

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

* Update data_structures/linked_list/singly_linked_list.py

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

* Update data_structures/linked_list/singly_linked_list.py

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

* Update data_structures/linked_list/singly_linked_list.py

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

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2020-09-25 16:09:29 +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
kanthuc
ecac7b0973
Contains loops.py add (#2442)
* added an algorithm which checks a linked list for loops and returns true if one is found

* added doctests and clarified meaning of loop

* Define Node.__iter__()

* Update and rename has_loop.py to has_duplicate_data.py

* Update has_duplicate_data.py

* Update has_duplicate_data.py

* Update and rename has_duplicate_data.py to has_loop.py

* Update has_loop.py

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-09-18 22:53:50 +02:00
Ashley Jeji George
1ac75f4683
Create priority_queue_using_list.py (#2435)
* Create priority_queue_using_list.py

* Update priority_queue_using_list.py

* Update priority_queue_using_list.py

* Update priority_queue_using_list.py

* Maximum queue size is 100

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-09-16 18:42:53 +02:00
Du Yuanchao
44b8cb0c81
Updated Stack (#2414)
* * Added type hints
* Added test
* Formated code

* updating DIRECTORY.md

* Update stack.py

* Test error conditions for pop, peek, and

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2020-09-13 13:56:03 +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
NEERAJ ADITYANANTH POLAMPALLI
3b1c4f72ce
changed a typo (#2396) 2020-09-05 13:09:18 +02:00
kanthuc
472f63eaa5
Adding type hints to RedBlackTree (#2371)
* redblacktree type hints

* fixed type hints to pass flake8
2020-08-30 21:22:36 +02:00
Aanuoluwapo Babajide
1f5134b368
Create alternate_disjoint_set.py (#2302)
* Create alternate_disjoint_set.py

This code implements a disjoint set using Lists 
with added heuristics for efficiency
Union by Rank Heuristic and Path Compression

* Update alternate_disjoint_set.py

Added typehints, doctests and some suggested variable name change

* Update alternate_disjoint_set.py

* Formatted with Black

* More formatting

* Formatting on line 28

* Error in Doctest

* Doctest Update in alternate disjoint set

* Fixed build error

* Fixed doctest
2020-08-28 18:25:02 +02:00
kanthuc
f8c57130f2
lazy_segment_tree.py-style-fixes (#2347)
* fixed variable naming and unnecessary type hints

* print(segt)

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-08-24 09:52:02 +02:00
SiddhantBobde
0bf1f22d37
Added function for finding K-th smallest element in BST (#2318)
* fixes: #2172

* fixes: #2172

* Added docstrings and type of parameters

* fixed error

* Added type hints

* made changes

* removed capital letters from function name

* Added type hints

* fixed bulid error

* modified comments

* fixed build error
2020-08-21 12:25:50 +05:30
Du Yuanchao
0591968947
Optimization and fix bug (#2342)
* * optimization aliquot_sum
* fix bug in average_median

* fixup! Format Python code with psf/black push

* Update maths/average_median.py

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-08-21 14:39:03 +08:00
kanthuc
2eaacee7b4
lowest_common_ancestor.py static type checking (#2329)
* adding static type checking to basic_binary_tree.py

* Add static type checking to functions with None return type

* Applying code review comments

* Added missing import statement

* fix spaciing

* "cleaned up depth_of_tree"

* Add doctests and then streamline display() and is_full_binary_tree()

* added static typing to lazy_segment_tree.py

* added missing import statement

* modified variable names for left and right elements

* added static typing to lowest_common_ancestor.py

* fixed formatting

* modified files to meet style guidelines, edited docstrings and added some doctests

* added and fixed doctests in lazy_segment_tree.py

* fixed errors in doctests

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-08-21 06:54:34 +02:00
Alex Joslin
d3199da000
Created Dijkstra's Two Stack Algorithm (#2321)
* created dijkstra's two stack algorithm

* Made changes to dijkstras two stack algorithm for documentation and
testing purposes.

* Made changes to dijkstras two stack algorithm for documentation and
testing purposes.

* Fixed Grammar Mistake

* Added Explanation Reference

* Imported stack instead of using my own
Changed a few minor things.

* Imported stack instead of using my own
Changed a few minor things.

* Update data_structures/stacks/dijkstras_two_stack_algorithm.py

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

* Update dijkstras_two_stack_algorithm.py

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-08-20 17:49:43 +02:00
Du Yuanchao
d687030d9e
fix number_of_digits bug (#2301)
* fix bug

* test larger negative

* fixup! Format Python code with psf/black push

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-08-12 18:32:35 +02:00
kanthuc
d25a926c02
adding static type checking to basic_binary_tree.py (#2293)
* adding static type checking to basic_binary_tree.py

* Add static type checking to functions with None return type

* Applying code review comments

* Added missing import statement

* fix spaciing

* "cleaned up depth_of_tree"

* Add doctests and then streamline display() and is_full_binary_tree()

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-08-11 23:38:38 +02:00
TheSuperNoob
b2e8672f02
Fix doubly linked list algorithm (#2062)
* Fix doubly linked list algorithm

* Fix bug with insert_at_tail method

Create __str__() method for Node class and LinkedList class

* Simplify __str__() of LinkedList

Returns empty string if there are no elements in the list

* Fix description
2020-08-02 23:55:18 +08:00
Sumuk Shashidhar
e2ee52d773
removed redundant data_structures folder (#2256) 2020-07-31 20:36:02 +02:00
Palash Sharma
ee282d3687
Update min_heap.py (#2245)
Changed min head to min heap in the first line.
2020-07-28 07:55:35 +02:00
Christian Clauss
5f4da5d616
isort --profile black . (#2181)
* updating DIRECTORY.md

* isort --profile black .

* Black after

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-07-06 09:44:19 +02:00
Christian Clauss
8ab84fd794
Only one carriage return (#2155)
* updating DIRECTORY.md

* touch

* fixup! Format Python code with psf/black push

* Update word_frequency_functions.py

* updating DIRECTORY.md

* Update word_frequency_functions.py

* Update lfu_cache.py

* Update sol1.py

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-06-25 19:15:30 +02:00
Markgolzh
c7ca9cf0df
Update avl_tree.py (#2145)
* Update avl_tree.py

it's true definition of AVL tree,change  left and right rotation,and add avl_tree doctest

* Update avl_tree.py

* Update data_structures/binary_tree/avl_tree.py

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

* Update data_structures/binary_tree/avl_tree.py

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

* Update data_structures/binary_tree/avl_tree.py

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

* Update data_structures/binary_tree/avl_tree.py

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

* Update data_structures/binary_tree/avl_tree.py

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

* Update data_structures/binary_tree/avl_tree.py

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

* Update data_structures/binary_tree/avl_tree.py

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

* Update data_structures/binary_tree/avl_tree.py

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

* Update data_structures/binary_tree/avl_tree.py

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

* Update data_structures/binary_tree/avl_tree.py

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

* Update data_structures/binary_tree/avl_tree.py

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

* Update avl_tree.py

update some function name and update doctest

* Update avl_tree.py

change some code format to fit flake8 review

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-06-25 09:55: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
Lakshmikanth2001
321b1425e3
data_structures/linked_list: Add __len__() function and tests (#2047)
* Update __init__.py

please add a function to get length of linked list

* Update __init__.py

* Update doubly_linked_list.py

all size function lo doubly linked list class

* prime number _better method

* comments

* Updated init.py 2

made it more pythonic

* updated length function

* commnet in linked_list construtor

* Update data_structures/linked_list/__init__.py

accepecting changes

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

* Update data_structures/linked_list/__init__.py

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

* Update __init__.py

* Revert changes to doubly_linked_list.py

* Revert changes to prime_check.py

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-05-31 11:37:45 +02:00
Christian Clauss
1e8fe8efcf
circular_linked_list: Add more len() tests (#2051)
* circular_linked_list: Add more len() tests

* fixup! Format Python code with psf/black push

* prepend()

* updating DIRECTORY.md

* Fix decrementation of self.length

* Add empty list tests

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-05-31 13:06:57 +05:30
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
0e6e5056b3
singly_linked_list.py: psf/black (#2008)
* singly_linked_list.py: psf/black

* updating DIRECTORY.md

* Update singly_linked_list.py

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-05-19 13:54:25 +02:00
Christian Clauss
1c62bd10c1
Precision must be a nonnegative integer (#2013)
* Precision must be a nonnegative integer

* fixup! Format Python code with psf/black push

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-05-19 15:46:20 +05:30
Akash
f9e0dd94d6
added __len__ function (#1812)
* added __len__ function

Added a function to count number of nodes in linked list

* Updated __len__ method

used snake_case instead of camel case

* Add tests to __len__()

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-05-18 18:10:55 +02:00
halilylm
1151d8b157
Add type hints to max_heap.py (#1960)
* Max heap implementation

* Update max_heap.py

* Update max_heap.py

* Update max_heap.py

* __len__ method added

* Update max_heap.py

Co-authored-by: halilpython <65048618+halilpython@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2020-05-11 12:23:39 +02:00
Vipul Rai
3d4ccc383a
change method name from front to get_front (#1943)
Co-authored-by: “Vipul <“vipulrai8891@gmail.com”>
2020-05-06 11:19:44 +05:30
Christian Clauss
d1b25760bc
Fix psf/black issues than fail the build (#1935)
* Fix psf/black issues than fail the build

* fixup! Format Python code with psf/black push

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-05-03 23:58:44 +02:00
Akash
b6fcee3114
Check if a item exist in stack or not (#1931)
* Check if a item exist in stack or not

* implemented __contains__ method in stack

* made changes in __contains__
2020-05-03 16:15:31 +02:00
lanzhiwang
853741e518
enhanced segment tree implementation and more pythonic (#1715)
* enhanced segment tree implementation and more pythonic

enhanced segment tree implementation and more pythonic

* add doctests for segment tree

* add type annotations

* unified processing sum min max segment tre

* delete source encoding in segment tree

* use a generator function instead of returning

* add doctests for methods

* add doctests for methods

* add doctests

* fix doctest

* fix doctest

* fix doctest

* fix function parameter and fix determine conditions
2020-05-02 21:44:29 +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
Christian Clauss
1ad78b2663
Fix invalid escape sequence in binary_search_tree.py (#1920)
* Fix invalid escape sequence in binary_search_tree.py

data_structures/binary_tree/binary_search_tree.py:156
  /home/travis/build/TheAlgorithms/Python/data_structures/binary_tree/binary_search_tree.py:156: DeprecationWarning: invalid escape sequence \

* fixup! Format Python code with psf/black push

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-05-01 02:17:11 +05:30
Christian Clauss
8bf380ce7d
README.md: sumab() --> sum_ab() for consistancy (#1855)
* README.md: sumab() --> sum_ab() for consistancy  

consistency

* fixup! Format Python code with psf/black push

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-04-12 17:18:30 +02:00
Sajied Shah Yousuf
c775baf55f
Added new Algorithm to find middle element of Linked List (#1822)
* Added new Algorithm to find middle element of Linked List

* Rename MiddleElementOfLinkedList.py to middle_element_of_linked_list.py

* changed "middle_element_of_linked_list.py" algorithm for taking input

* Update middle_element_of_linked_list.py

* Update middle_element_of_linked_list.py

* Update middle_element_of_linked_list.py

* Update middle_element_of_linked_list.py

* Update middle_element_of_linked_list.py

* Update middle_element_of_linked_list.py

* Update middle_element_of_linked_list.py

* Update middle_element_of_linked_list.py

* Update middle_element_of_linked_list.py

* Whack the trailing whitespace

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-04-12 16:45:07 +02:00
Joan Martin Miralles
a38e143cf8
Binary search tree using recursion (#1839)
* Binary search tree using recursion

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-04-07 18:09:05 +02:00
Prince Gangurde
6043a44ffb
Update basic_binary_tree.py (#1833)
fixed some grammar mistakes
2020-04-07 00:59:32 +02:00
Christian Clauss
f17e9822b0
psf/black changes to next_greater_element.py (#1817)
* psf/black changes to next_greater_element.py

* fixup! Format Python code with psf/black push

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-03-28 07:24:59 +01:00
Vaibhav Singh
96df906e7a
All suggeted changes within additional time limit tests (#1815)
* With all suggested changes  

possibly covered all the recommended guidelines

* Updated with both slow and faster algorithms

possibally covered all the recomendations

* removed the time comparision part!

* Update data_structures/stacks/next_greater_element.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 data_structures/stacks/next_greater_element.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>

* Add benchmark using timeit

https://docs.python.org/3/library/timeit.html

The performance delta between these two implementation is quite small...
```
next_greatest_element_slow(): 1.843442126
     next_greatest_element(): 1.828941414
```

* Optimize slow() to create fast() - Three algorithms in the race

Three algorithms in the race

* Use a bigger test array with floats, negatives, zero

* Setup import next_greatest_element_fast

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-03-27 08:16:07 +01:00
KDH
45524dd6d3
Fix rehashing function will not call insert_data function (#1803)
* Fix rehashing function will not call insert_data function

* Fix typo

* Update loop syntax instead of allocating a list

Co-Authored-By: Christian Clauss <cclauss@me.com>

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-03-16 11:19:13 +01:00
KDH
cb5f8c6e4e
Fix typo (#1797)
colision => collision
2020-03-13 13:46:52 +01:00
Christian Clauss
a9f73e318c
Added SkipList (#1781)
* Added SkipList

* Add missing type hints and doctests

* Add missing doctest

* Tighten up doctest

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-03-05 17:57:43 +01:00
matkosoric
7f04e5cd34
contribution guidelines checks (#1787)
* spelling corrections

* review

* improved documentation, removed redundant variables, added testing

* added type hint

* camel case to snake case

* spelling fix

* review

* python --> Python # it is a brand name, not a snake

* explicit cast to int

* spaces in int list

* "!= None" to "is not None"

* Update comb_sort.py

* various spelling corrections in documentation & several variables naming conventions fix

* + char in file name

* import dependency - bug fix

Co-authored-by: John Law <johnlaw.po@gmail.com>
2020-03-04 13:40:28 +01:00
onlinejudge95
4866b1330b
Fixes black failures from Previous PR (#1751)
* Fixes black failures from Previous PR

* Fixes equality testing alert

* Fixes call to main() alert

* Fixes unused import
2020-02-13 02:19:41 +05:30
onlinejudge95
7b7c1a0135
Fixes unused variable errors in LGTM (#1746)
* Fixes unsed variable errors in LGTM

* Fixes integer check

* Fixes failing tests
2020-02-11 13:59:09 +05:30
Christian Clauss
bfcb95b297
Create codespell.yml (#1698)
* fixup! Format Python code with psf/black push

* Create codespell.yml

* fixup! Format Python code with psf/black push
2020-01-18 13:24:33 +01:00
lanzhiwang
fc4c0f5bfd implement max heap and more pythonic (#1685)
* implement max heap and more pythonic

* add doctests for heap
2020-01-14 12:16:11 +01:00
Logan Lieou
d09a805804 Typo? (#1653)
* Typo?

newNod -> newNode

* newNode -> new_node

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-01-14 10:21:02 +01:00
lanzhiwang
56e7ae01d2 enhance swapping code in link (#1660)
* enhance swapping code in link

* heapify do not recursive

* fix

* fix identifier and add test

* typing.Any and LinkedList instead of Linkedlist

* typing.Any and LinkedList instead of Linkedlist
2020-01-14 14:32:15 +05:30
Leon Morten Richter
4607cd48b6 Add a program to evaluate a string in prefix notation (Polish Notation) (#1675)
* Create infix_evaluation.py

* fix doctests

* Rename infix_evaluation.py to prefix_evaluation.py

* Add prefix_evaluation.py to directory
2020-01-12 15:00:40 +05:30
Christian Clauss
e849578e59 Update and rename lca.py to lowest_common_ancestor.py (#1664)
* Update and rename lca.py to lowest_common_ancestor.py

* fixup! Format Python code with psf/black push
2020-01-08 21:15:41 +08:00
Christian Clauss
1f2b1a88ab Typos in comments in hill_climbing.py (#1667)
* Typos in comments in hill_climbing.py

* fixup! Format Python code with psf/black push
2020-01-08 21:06:53 +08:00
MadhavCode
46df735cf4 New Code!!(Finding the N Possible Binary Search Tree and Binary Tree from Given N node Number) (#1663)
* Code Upload

* Code Upload

* Delete n_possible_bst

* Find the N Possible Binary Tree and Binary Tree from given Nth Number of Node.

* Update in Test

* Update and rename n_possible_bst.py to number_of_possible_binary_trees.py

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-01-07 10:17:35 +01:00
Himanshu Bhatnagar
b212a59754 Create deque_doubly.py (#1652)
* Create deque_doubly.py

Implementing Deque ADT using Doubly Linked List....

* Update deque_doubly.py

* Update deque_doubly.py

Adding doctest

* Update doctest of deque_doubly.py

* Update deque_doubly.py

* linked_list.

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-01-05 10:51:03 +01:00
Christian Clauss
28419cf839 pyupgrade --py37-plus **/*.py (#1654)
* pyupgrade --py37-plus **/*.py

* fixup! Format Python code with psf/black push
2020-01-03 22:25:36 +08:00
Christian Clauss
34c808b375 actions/checkout@v2 (#1643)
* actions/checkout@v2

https://github.com/actions/checkout/releases

* fixup! Format Python code with psf/black push
2019-12-26 19:50:12 +08:00
Dhakad9
aa18600e22 Stack using double linked list (#1413)
* Stack using double linked list

* Test with doctests

* Update stack_using_dll.py

* Update stack_using_dll.py

* Update stack_using_dll.py

Co-authored-by: Christian Clauss <cclauss@me.com>
2019-12-21 02:46:49 +01:00
Hocnonsense
81ae5adcc8 Update binary_search_tree.py (#1339)
* Update binary_search_tree.py

remove some bugs

* Update binary_search_tree.py

* Update binary_search_tree.py

* Update binary_search_tree.py

* Update binary_search_tree.py

* Update binary_search_tree.py

* Update binary_search_tree.py

* testlist = (8, 3, 6, 1, 10, 14, 13, 4, 7)

* Update .travis.yml

Co-authored-by: Christian Clauss <cclauss@me.com>
2019-12-21 01:44:31 +01:00
GeorgeChambi
9eb50cc223 Improved readability (#1615)
* improved readability

* further readability improvements

* removed csv file and added f
2019-12-07 06:39:59 +01:00
Níkolas Vargas
938dd0bbb5 improved prime numbers implementation (#1606)
* improved prime numbers implementation

* fixup! Format Python code with psf/black push

* fix type hint

* fixup! Format Python code with psf/black push

* fix doctests

* updating DIRECTORY.md

* added prime tests with negative numbers

* using for instead filter

* updating DIRECTORY.md

* Remove unused typing.List

* Remove tab indentation

* print("Sorted order is:", " ".join(a))
2019-12-07 06:39:08 +01:00
Saurabh Goyal
5d20dbfb98 add a generic heap (#906)
* add a generic heap

* Delete __init__.py

* Rename data_structures/Heap/heap_generic.py to data_structures/heap/heap_generic.py

* Add doctests

* Fix doctests

* Fix doctests again
2019-11-30 06:17:13 +01:00
Vikas Kumar
0d3c9d586c Update singly_linked_list.py (#1593)
* Update singly_linked_list.py

printing current.data rather than node address in __repr__ for a more readable print statement

* eval(repr(c)) == c

The output of `__repr__()` _should look like a valid Python expression that could be used to recreate an object with the same value_.

https://docs.python.org/3.4/reference/datamodel.html#object.__repr__

* += --> +
2019-11-26 06:45:28 +01:00
Christian Clauss
ec7bc7c7cd Tabs --> spaces in quine_mc_cluskey.py (#1426)
* Tabs --> spaces in quine_mc_cluskey.py

* fixup! Format Python code with psf/black push
2019-11-21 22:21:40 +08:00
onlinejudge95
c57c4ca1a1 Adds operations for circular linked list (#1584)
* Adds, append, len, print operations for circular linked list

* Adds, prepend support

* Adds, delete from front of the list

* Adds, delete_rear support

* Adds, method documentations

* Adds, type checking and doctests

* Updates doctest for delete ops

* Addressing requested changes

* Removes unused import

* Fixes failing doctests

* Minor modifications...
2019-11-19 10:53:44 +01:00
Himanshu Bhatnagar
0832e1ec58 Adding circular_queue.py (#1574)
* Create circular_queue.py

Circular Queue implementation using python list with fixed range.

* Update circular_queue.py

* Update circular_queue.py

* Update circular_queue.py

* Update circular_queue.py

* Update circular_queue.py

* doctest: Catch "Exception: UNDERFLOW"

* Deal with the fluent interface for cq.enqueue()

* Test the fluent interface
2019-11-17 19:59:50 +01:00
Christian Clauss
b838f1042c Fix indentation contains tabs (flake8 E101,W191) (#1573) 2019-11-15 23:05:00 -08:00
Christian Clauss
5df8aec66c
GitHub Action formats our code with psf/black (#1569)
* GitHub Action formats our code with psf/black

@poyea Your review please.

* fixup! Format Python code with psf/black push
2019-11-14 19:59:43 +01:00
Hanif Ali
4c37eb7d07 Improved on Singly Linked List Programs (#1558)
* Improved Singly Linked List
Added String Representations of Nodes and Linked Lists
Added support for indexing and changing of Node data using indices.

* Added a few comments to Linked Lists

* Reformatted to conform to PEP8

* Added from_sequence.py
Convert a Python List to Linked List comprising of Nodes and return head.

* Added print_reverse.py
Recursive program to print the elements of a Linked List in reverse.

* Change 'is not None' for more Pythonicness
2019-11-10 09:47:04 +01:00
Jonathan Alberth Quispe Fuentes
7bc0462e79 Non-recursive Segment Tree implementation (#1543)
* Non-recursive Segment Tree implementation

* Added type hints and explanations links
2019-11-01 04:00:46 +01:00
himanshujain171
53ff735701 Factors of a number (#1493)
* Factors of a number

* Update factors.py

* Fix mypy issue in basic_maths.py

* Fix mypy error in perceptron.py

* def primes(max: int) -> List[int]:

* Update binomial_heap.py

* Add a space

* Remove a space

* Add a space
2019-10-29 23:54:30 +01:00
Samarth Sehgal
a2a3ca674f Update treap.py (#1455) 2019-10-25 17:56:27 +02:00
Ankur Chattopadhyay
7592cba417 psf/black code formatting (#1421)
* added sol3.py for problem_20

* added sol4.py for problem_06

* ran `black .` on `\Python`
2019-10-22 19:13:48 +02:00
Manu M Bhat
cd10c944d1 Issue #1397 (#1403) 2019-10-19 20:14:37 +02:00
Jai Kumar Dewani
5ef5f67a51 Added more details about the problem statement (#1367)
* Update DIRECTORY

* Updated DIRECTORY

* Fixed bug in directory build and re-build the directory.md

* fixed url issue

* fixed indentation in Directory.md

* Add problem-18 of project-euler

* Delete sol1.py

* Delete files

* Added more details to question

* Added doctest in printNGE()

* Made changes to fix Travis CI build

* Remove the trailing whitespace
2019-10-18 21:14:01 +02:00
Hocnonsense
179284a41b Update treap.py (#1358)
* Update treap.py

check merge()

* Update treap.py

random() is used. its difficult to write doctests
l->left
r->right
key->value
add __repr__ and __str__ in preorder
2019-10-18 09:39:37 +02:00
Mariusz Skoneczko
7376addcd5 Implement Linked Queue and Linked Stack data structures (#1324)
* Add LinkedQueue

* Add LinkedStack
2019-10-18 08:38:31 +02:00
Nishant-Ingle
06d736199b Added comment (#1294) 2019-10-07 23:29:14 +05:00
William Zhang
9eac17a408 psf/black code formatting (#1277) 2019-10-05 10:14:13 +05:00
yijoonsu
189b350312 Deque (#1200)
* deque add pop

* deque add remove
2019-09-30 16:27:41 +02:00
Raj
6ac7b1387f Min head with decrease key functionality (#1202)
* Min head with decrease key functionality

* doctest added

* __str__ changed as per Python convention

* edits in doctest

* get_value by key added

* __getitem__ added
2019-09-26 00:03:31 +02:00
luoheng
01601e6382 Add disjoint set (#1194)
* Add disjoint set

* disjoint set: add doctest, make code more Pythonic

* disjoint set: replace x.p with x.parent

* disjoint set: add test and refercence
2019-09-23 05:08:20 +02:00
Denis Trofimov
04962c0d17 Fix lgtm error display #1024 (#1190)
* fix: Syntax Error lgtm display in matrix/matrix_operation.py.

* Testing for None should use the 'is' operator.

* fix: Too many arguments for string format.

* fix: supress lgtm alert as false positive.

* style: Unnecessary 'pass' statement.

* Revert "fix: Syntax Error lgtm display in matrix/matrix_operation.py."

This reverts commit 4c629b4ce1.
2019-09-21 16:23:34 +02:00
Sangeet K
768700b91f Add delete to trie.py + tests (#1177)
* Add delete to trie.py + tests

* Minor fixes + tests

* Remove noqa comments + modify tests for Travis CI to detect

* Minor improvement
2019-09-13 22:24:25 +02:00
KirilBangachev
f31a812c46 Add Binomial Heap (#1146)
* Binomial Heap

Implementation of Binomial Heap. Reference: Advanced Data Structures, Peter Brass

* Update binomial_heap.py

* Update binomial_heap.py

* Update binomial_heap.py

- Fuller documentation of binomial heap
- Update unit tests
- Replace printing method by overwriting __str__()

* Update binomial_heap.py

- Added more tests
- Added to the documentation
- Stylistic editing
- mergeHeaps now also returns a reference to the merged heap
- added a preOrder function that returns a list with the preorder of the heap

* Update binomial_heap.py

Changed the unit tests structure

* Turned the tests into doctests
2019-09-05 07:58:37 +02:00
Christian Clauss
47a9ea2b0b
Simplify code by dropping support for legacy Python (#1143)
* Simplify code by dropping support for legacy Python

* sort() --> sorted()
2019-08-19 15:37:49 +02:00
Christian Clauss
89acf5d017 print() is a function just like every other function (#1101)
* print() is a function just like every other function
2019-08-06 12:14:23 +02:00
Christian Clauss
7b267e5e4f Fix data_structures to pass our Travis CI pytests (#1088)
* Fix data_structures to pass pytests

* Restore data_structures/stacks/__init__.py
2019-07-31 23:14:35 +08:00
QuantumNovice
c27bd5144f in_static_equilibrium checks if a 2D static system is in equilibrium (#1062)
* Add files via upload

* Add files via upload

* Create .a

* Add files via upload

* Add files via upload

* Rename static_solver.py to in_static_equilibrium.py

* Delete .a

* Update in_static_equilibrium.py

* Add files via upload

* Add files via upload

* Update in_static_equilibrium.py

* Add files via upload

* Add files via upload

* Add files via upload

* Add files via upload

* pyTests added

* Add files via upload

* Delete red_black_tree.py

* Add files via upload
2019-07-25 20:38:24 +02:00
Bruno Simas Hadlich
267b5eff40 Added doctest and more explanation about Dijkstra execution. (#1014)
* Added doctest and more explanation about Dijkstra execution.

* tests were not passing with python2 due to missing __init__.py file at number_theory folder

* Removed the dot at the beginning of the imported modules names because 'python3 -m doctest -v data_structures/hashing/*.py' and 'python3 -m doctest -v data_structures/stacks/*.py' were failing not finding hash_table.py and stack.py modules.

* Moved global code to main scope and added doctest for project euler problems 1 to 14.

* Added test case for negative input.

* Changed N variable to do not use end of line scape because in case there is a space after it the script will break making it much more error prone.

* Added problems description and doctests to the ones that were missing. Limited line length to 79 and executed python black over all scripts.

* Changed the way files are loaded to support pytest call.

* Added __init__.py to problems to make them modules and allow pytest execution.

* Added project_euler folder to test units execution

* Changed 'os.path.split(os.path.realpath(__file__))' to 'os.path.dirname()'
2019-07-17 01:09:53 +02:00
Alfonso Rodríguez Pereira
5f991f7740 #315 Renamed all files to snake_case (#993) 2019-07-11 11:16:42 +02:00
Anup Kumar Panwar
4e413c0183 Updated README 2019-07-06 11:11:20 +05:30
Jarred Allen
506bb5ccfe Add Red-Black Binary Search Trees (#954)
* Wrote most of an rbt, missing just removal

* Added some convenience methods.

* Added a color method

* Wrote code to delete, but has issues :(

* Fixed a bug in Red-Black trees

* Fixed bug in tree color validation and delete repairing

* Clean up == comparison to None
2019-07-05 14:13:16 +05:30
Hector S
05e5172093 .vs/ directory, matrix_multiplication_addition file and binary tree directory (#894)
* Added print function into matrix_multiplication_addition.py and removed blank space in data_structures/binary tree directory

* Removed .vs/ folder per #893

* Rename matrix_multiplication_addition.py to matrix_operation.py
2019-06-11 19:24:53 +08:00
luanjerry
f386fce820 Update queue_on_list.py (#851)
* Fixed error in queue_on_list.py
2019-05-31 16:05:24 +08:00
Anup Kumar Panwar
71be23999c refactor 2019-05-26 21:56:10 +05:30
Artyom Belousov
94380a17a8 Added treap (#797)
* Added treap

* Added comments to treap
2019-05-26 06:20:37 +08:00
John Law
48bba495ae
Rename is_Palindrome to is_Palindrome.py (#752) 2019-04-20 15:13:02 +08:00
Reshad Hasan
52d2fbf3cf Add lowest common ancestor to data structures (#732)
* add longest common ancestor in data structures

* add lowest common ancestor to data structures
2019-04-10 23:59:49 +08:00
rohan11074
137871bfef feature to add input (#749) 2019-04-07 23:55:32 +08:00
Ishani
15bc87fb41 Create is_Palindrome (#740) 2019-04-04 16:40:11 +05:30
Maxim Semenyuk
8e67ac3b76 Fix '__bool__' method (#735)
The method returns the truth when the stack is empty
2019-03-10 07:40:29 +05:30
Akash Ali
6f6510623c Update heap.py (#726)
Added comments for the better understanding of heap.
2019-03-04 16:49:36 +08:00
Ashwek Swamy
88b6caa30a fixed balanced_parentheses, Added infix-prefix & postfix evaluation (#621)
* Create infix_to_prefix_conversion.py

* Create postfix_evaluation.py

* Update balanced_parentheses.py
2019-03-02 00:53:29 +08:00
Reshad Hasan
9a44eb4479 Organize graph algorithms (#719)
* organized graph algorithms

* all graph algorithms in Graphs/ folder

* all graph algorithms are in one folder

* Rename number theory/factorial_python.py to maths/factorial_python.py
2019-02-25 17:35:24 +08:00
Mickaël Schoentgen
3dc50529ca Fix DeprecationWarning: invalid escape sequence (#679)
Signed-off-by: Mickaël Schoentgen <contact@tiger-222.fr>
2019-01-08 16:58:47 +08:00
Jithendra Yenugula
d26311424d Adding a program for swap nodes in linkedlist (#667)
* Adding a program for swap nodes in linkedlist

* Updating swapNodes
2018-12-25 21:09:36 +08:00
Mikael Souza
2e2fadf4db Fixed bug where an empty stack would cause error 2018-12-17 10:45:54 -04:00
Mikael Souza
a8cfc14737 Added more parentheses examples 2018-12-17 10:45:16 -04:00
Mikael Souza
2d082cf19c Changed import from .Stack to stack 2018-12-17 10:44:38 -04:00
Harshil
72c217c37e
Update AVLtree.py
Removed blank lines (256 to 287)!
2018-11-23 18:23:06 +01:00
Awfifcuihc
9bbc4d9021 Update AVLtree.py
add comments
2018-11-22 14:33:50 +08:00
Awfifcuihc
d1dba51326
remove commented lines 2018-11-21 12:46:32 +08:00
Awfifcuihc
9f96c155be Update AVLtree.py
add delete function
add demo with shuffled list
add print lines to trace the addition or deletion
2018-11-21 03:25:07 +08:00
Awfifcuihc
6001215b60 Update AVLtree.py
An auto balanced binary tree
with no delete node function
leave for latter
2018-11-20 03:41:52 +08:00
Awfifcuihc
16cc96a092 Create AVLtree.py 2018-11-20 03:34:44 +08:00
Yasser A
840aa6209b fix division by float issue in range heap.py 2018-11-06 17:19:51 -05:00
Rafael García Cuéllar
beafe3656f Re-design psnr.py code and change image names (#592)
* Change some Image File names & re-code the psnr algorithm (conserving both methods). Also Added new example.

* Selected psnr method and reformat some code from arithmetic_analysis
2018-11-05 18:19:08 +01:00