* 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>
* 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>
* 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>
* 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>
* 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
* 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
* 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>
* 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>
* 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>
* 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
* 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>
* 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>
* 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>
* 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>
* 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>
* 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
* 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>
* 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>
* 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>
* 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
* 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>
* 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>
* 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))
* 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__
* += --> +
* 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...
* 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
* 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
* 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
* 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