Commit Graph

35 Commits

Author SHA1 Message Date
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
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
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
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
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
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
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
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
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
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
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
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
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
Christian Clauss
b838f1042c Fix indentation contains tabs (flake8 E101,W191) (#1573) 2019-11-15 23:05:00 -08: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
Mariusz Skoneczko
7376addcd5 Implement Linked Queue and Linked Stack data structures (#1324)
* Add LinkedQueue

* Add LinkedStack
2019-10-18 08:38:31 +02:00
William Zhang
9eac17a408 psf/black code formatting (#1277) 2019-10-05 10:14:13 +05: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
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
Anup Kumar Panwar
4e413c0183 Updated README 2019-07-06 11:11:20 +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
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
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
Hrushikesh Hanbar
f1ec84af84 Update balanced_parentheses.py (#538) 2018-10-30 15:29:12 +01:00
Alex Brown
91fccecb56 snake_case all the things 2018-10-19 17:14:25 -05:00
Alex Brown
564179a0ec increment 1 2018-10-19 07:48:28 -05:00