Commit Graph

239 Commits

Author SHA1 Message Date
yellowsto
6680e435a7
Update merge_insertion_sort.py (#5833)
* Update merge_insertion_sort.py

Fixes #5774

merge_insertion_sort

Co-Authored-By: AilisOsswald <44617437+AilisOsswald@users.noreply.github.com>

* Update merge_insertion_sort.py

Fixes #5774

merge_insertion_sort

Co-Authored-By: AilisOsswald <44617437+AilisOsswald@users.noreply.github.com>

* Update merge_insertion_sort.py

Fixes #5774

added permutation range from 0 to 4

Co-Authored-By: AilisOsswald <44617437+AilisOsswald@users.noreply.github.com>

* Use `all()`

Co-authored-by: AilisOsswald <44617437+AilisOsswald@users.noreply.github.com>
Co-authored-by: John Law <johnlaw.po@gmail.com>
2021-12-16 17:27:15 +08:00
Connor Bottum
31061aacf2
fix: use += in sorts/recursive_mergesort_array.py (#5019) 2021-10-27 00:43:46 +08:00
Manan Rathi
50485f7c8e
Fix typos in Sorts and Bit_manipulation (#4949)
* Fix several typos

* Update bit_manipulation/README.md

Co-authored-by: John Law <johnlaw.po@gmail.com>

* Update double_sort.py

Co-authored-by: John Law <johnlaw.po@gmail.com>
2021-10-20 16:42:32 +08:00
Sarvesh Kumar Dwivedi
90db98304e
Fix word typos in comments (#4928)
* fixed: spelling

nonegative -> non-negative

* fixed: spelling

transpostiion -> transposition

* fixed: spelling

topolical -> topological

* fixed: spelling

sufix -> suffix
2021-10-04 12:07:58 +08:00
Nolan Emirot
d530d2bcf4
fix: comment in patience sort (#4972) 2021-10-04 11:33:42 +08:00
Christian Clauss
cecf43d648
Pyupgrade to Python 3.9 (#4718)
* Pyupgrade to Python 3.9

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2021-09-07 13:37:03 +02:00
Kiran Hipparagi
757d4fb84f
Added Dutch National Flag algorithm #4636 (#4639)
* Added Dutch national flag sort Algorithm

* Changed file name to dnf_sort.py

* Added descriptive name and type hint 

Added descriptive name and type hint  for parameter with doctest for the function dnf_sort.

* Added test cases

* Added doctest cases

* Update sorts/dnf_sort.py

* Added doctest for dutch_national_flag_sort sorts/dnf_sort.py

* Update sorts/dnf_sort.py

* Added doctest for the function
dutch_national_flag_sort

* update file as per black code formatter

* Update dnf_sort.py

* Update and rename dnf_sort.py to dutch_national_flag_sort.py

Co-authored-by: Christian Clauss <cclauss@me.com>
2021-08-31 22:06:49 +02:00
Bonnie
032999f36e
Create exchange_sort.py (#4600)
* Create exchange_sort.py

added exchange sort

* Fixed doctest in exchange_sort.py

* Fixed formatting error and added new length variable

added empty line at end of exchange_sort.py and turned len(numbers) into a variable

* Fixed formatting errors with black

added empty line
2021-08-15 07:43:05 +02:00
Benjamin Fein
650039a279
Add a recursive merge sort algorithm that accepts an array as input. (#4462)
This is a different recursive implementation of the merge sort algorithm.

* Recursive Merge Sort That Accepts an Array 

Recursive Merge Sort That Accepts an Array

* Add Wikipedia Link

* Fixes naming conventions

* Update sorts/recursive_mergesort_array.py

Co-authored-by: Maxim R. <49735721+mrmaxguns@users.noreply.github.com>

* Update sorts/recursive_mergesort_array.py

Co-authored-by: Maxim R. <49735721+mrmaxguns@users.noreply.github.com>

* Update sorts/recursive_mergesort_array.py

Co-authored-by: Maxim R. <49735721+mrmaxguns@users.noreply.github.com>

* Update sorts/recursive_mergesort_array.py

Co-authored-by: Maxim R. <49735721+mrmaxguns@users.noreply.github.com>

* Update sorts/recursive_mergesort_array.py

Co-authored-by: Maxim R. <49735721+mrmaxguns@users.noreply.github.com>

* Adds black format

* Removes unused variables

* Fixes variable names and adds documentation

* Fixes variable names to use snake_case.

* Removes double #.

* Update sorts/recursive_mergesort_array.py

Co-authored-by: Maxim R. <49735721+mrmaxguns@users.noreply.github.com>

Co-authored-by: Maxim R. <49735721+mrmaxguns@users.noreply.github.com>
Co-authored-by: Benjamin Fein <benfein78@icloud.com>
2021-05-30 10:27:42 -05:00
Tobias
b913a0d83a
Implemented MSD radix sort algorithm in-place (#4449)
* Implemented MSD radix sort algorithm inplace

* Fixed formatting
2021-05-24 22:36:57 +02:00
Tobias
b11e5314b7
Added implementation for MSD radix sort algorithm based on binary representation (#4441)
* Added MSD radix sort algorithm

* Fixed typos

* Added doctests

* Added link to wikipedia

* Added doctest and improved code
2021-05-20 21:15:51 +02:00
杜远超
67b33a295b
Optimization shell sort (#4119)
* optimization

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2021-02-26 09:01:50 +08:00
Matthew
a4726ca248
[mypy]Correction of all errors in the sorts directory (#4224)
* [mypy] Add/fix type annotations for recursive_insertion_sort(#4085)

* [mypy] Add/fix type annotations for bucket_sort(#4085)

* [mypy] Reworked code for cocktail_shaker_sort so that missing return statement error is resolved(#4085)

* [mypy] Add/fix type annotations for patience_sort(#4085)

* [mypy] Add/fix type annotations for radix_sort(#4085)

Co-authored-by: goodm2 <4qjpngu8mem8cz>
2021-02-23 10:02:30 +01:00
Matthew
81c46dfd55
[mypy] Add/fix type annotations for quick_sort(#4085) (#4215)
Co-authored-by: goodm2 <4qjpngu8mem8cz>
2021-02-20 23:10:23 +01:00
MarineJoker
78ddb46066
Quick sort with lomuto partition (#3875)
* add quick sort algorithm with Lomuto partition

* fix(lomuto_partition): fix snake_case
2021-02-17 15:28:50 +01:00
Ocean Monjur
f66325a01b
odd_even_sort.py (#4199)
* odd_even_sort.py

* Update odd_even_sort.py

* Update odd_even_sort.py
2021-02-11 17:49:53 +01:00
Abdeldjaouad Nusayr Medakene
4903a65779
Create slowsort.py (#3865)
* Create slowsort.py

added slowsort algorithm implementation to sorts

* Update slowsort.py

* Update slowsort.py

* Update slowsort.py

* Update slowsort.py

* Update slowsort.py

* Update slowsort.py

* Update slowsort.py

* Update slowsort.py

* Update slowsort.py

* Update slowsort.py

* Update slowsort.py

* Update slowsort.py
2021-02-09 17:13:48 +01:00
Du Yuanchao
53371b2381
Optimization for shell sort (#4038)
* fixed shell sort

* udpate code style

* Update sorts/shell_sort.py

Co-authored-by: John Law <johnlaw.po@gmail.com>

Co-authored-by: John Law <johnlaw.po@gmail.com>
2020-12-18 10:39:51 +01:00
Jogendra Singh
c359768e25
Update bitonic_sort with type hints, doctest, snake_case names (#4016)
* Updated input
* Fix pre-commit error
* Add type hints, doctests, black, snake_case

Co-authored-by: Dhruv Manilawala <dhruvmanila@gmail.com>
2020-12-09 11:38:49 +05:30
Dhruv Manilawala
f8b2c43fda
Fix pre-commit error on master (#3992)
* Update pigeon_sort.py

* updating DIRECTORY.md

* Add type hints and return annotation

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-11-30 21:03:29 +05:30
wuyudi
07a4ce9fb8
Update pigeon_sort.py (#2359)
* Update pigeon_sort.py

* Update pigeon_sort.py

* Update pigeon_sort.py
2020-11-30 20:29:23 +05:30
YeonJeongLee00
2b50aaf2d3
Create intro_sort.py (#3877)
* Create intro_sort.py

* modified intro_sort.py

* add doctest

* modified code

black intro_sort.py

* add more test

* Update intro_sort.py

added doctest, modified code

* black intro_sort.py

* add type hint

* modified code
2020-11-25 09:54:31 +01:00
Marcos Vinicius
a1e9656eca
Hacktoberfest: adding doctest to radix_sort.py file (#2779)
* adding doctest to radix_sort.py file

* fixup! Format Python code with psf/black push

* Update radix_sort.py

* Update radix_sort.py

* fixup! Format Python code with psf/black push

* Update radix_sort.py

* line

* fix tests

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: John Law <johnlaw.po@gmail.com>
2020-10-29 11:09:39 +08:00
JoaoVictorNascimento
79d57552aa
Add Patience Sort (#3469)
* Add Patience Sort

* fix code for pre-commit

* Fix params def

* Adding new line at end of file

* Remove Trailing Whitespace

* Adding space between the methods of the Stack class

* Removing Trailing Whitespace

* Ordering Imports

* Adding url patience sort

Co-authored-by: jvnascimento <nascimento783@gmail.com>
2020-10-18 23:44:19 +02:00
Christian Clauss
2e90debab3
Tighten up quicksort() (#3319)
* Tighten up quicksort()

* updating DIRECTORY.md

* str does not support .pop()

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-10-15 15:07:34 +02:00
Mozartus
f0033f87e0
Create natural_sort.py (#3286)
* add natural_sort.py

* fix doctest

* add 're' to requirements.txt and fix spelling errors

* delete 're' from requirements.txt

* fixing linting errors

* Update sorts/natural_sort.py

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

* Update sorts/natural_sort.py

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

* Update natural_sort.py

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-10-15 13:45:17 +02:00
Du Yuanchao
43f92490fe
Update insert sort (#2493)
* delete duplicate file
update insert sort

* rename

* fixed error

* using enumerate()
2020-10-03 20:49:08 +05:30
Du Yuanchao
9b3f7c36d0
Test random input for bubble sort (#2492) 2020-10-02 13:55:58 +08:00
Du Yuanchao
2fa009aa53
Fix bucket sort (#2494)
* fixed bucket sort

* delete blank line
2020-10-01 08:53:42 +08:00
Dhruv
0a42ae9095
Fix all errors mentioned in pre-commit run (#2512)
* Fix all errors mentioned in pre-commit run:

- Fix end of file
- Remove trailing whitespace
- Fix files with black
- Fix imports with isort

* Fix errors
2020-09-30 10:38:00 +02:00
Lewis Tian
e166350509
Update sorts/quick_sort_3_partition.py (#2507)
* Update sorts/quick_sort_3partition.py

Another quick sort algorithm, returns a new sorted list

* Update sorts/quick_sort_3_partition.py

rename quick_sort_3partition to quick_sort_3part

* Update sorts/quick_sort_3_partition.py

rename quick_sort_3part to three_way_radix_quicksort
Three-way radix quicksort:
https://en.wikipedia.org/wiki/Quicksort#Three-way_radix_quicksort
First divide the list into three parts.
Then recursively sort the "less than" and "greater than" partitions.

* Update sorts/quick_sort_3_partition.py

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

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-09-29 13:55:48 +02:00
Dhruv
48357cea5b
Add __init__.py files in all the directories (#2503) 2020-09-28 19:42:36 +02:00
Guillaume Rochedix
f564c9d7c6
Wiggle sort (#2419)
* wiggle sort : type hint + doctest

* fixed function name in docstring

* correction
2020-09-25 09:18:00 +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
Christian Clauss
363858ef3b
hyphen_files = [file for file in filepaths if "-" in file] (#2447)
* hyphen_files = [file for file in filepaths if "-" in file]

* updating DIRECTORY.md

* Rename recursive-quick-sort.py to recursive_quick_sort.py

* updating DIRECTORY.md

* Rename aho-corasick.py to aho_corasick.py

* updating DIRECTORY.md

* Rename polynom-for-points.py to polynom_for_points.py

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-09-19 07:13:10 +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
小么小儿郎EL
80daa5750a
Fix bugs and add related tests (#2375) 2020-08-31 18:55:56 +02:00
wuyudi
cf385ad7ef
Update merge_sort.py (#2356)
* Update merge_sort.py

* Update merge_sort.py
2020-08-27 09:45:03 +02:00
Christian Clauss
ee914c751c
Delete sleep_sort.py (#2352)
* Delete sleep_sort.py

A silly algorithm designed to waste time.  #2350 demonstrates that it is a 20+ second denial of service attack on every Travis CI run that we do.

* fixup! Format Python code with psf/black push

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-08-25 15:48:04 +02:00
Guillaume Rochedix
ee28deea4a
Insertion sort : type hint, docstring (#2327)
* insertion sort : docstring, type hinting

* Update insertion_sort.py

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-08-23 04:35:54 +02:00
Guillaume Rochedix
fcc8a28c31
Gnome sort : type hints, docstrings, doctests (#2307)
* gnome_sort : type hints, docstring, doctests

* !Gadeimnoprstu

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-08-14 22:00:08 +02:00
ryuta69
9ec71cbdda
Add merge insertion sort (#2211)
* Add merge insertion sort

* Fix python naming conventions

* Add wikipedia link

* Add type hint

* Fix python to python3

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

* Refactor doubled process in if-condition into one outside of if-condition

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

* Refactor make python3 prior to python

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

* Fix name of is_surplus into has_last_odd_item

* Add comment

* Fix long comment to shorten

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-07-20 22:42:08 +05:30
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
mateuszz0000
b0c3c0fbf6
Typehints + refactor (#2154) 2020-06-25 09:48:52 +02:00
mateuszz0000
9e2206e5fb
Added doctests to OddEvenTraposition (#2152)
* Added doctests

* Change __main__ content
2020-06-25 08:56:57 +02:00
Christian Clauss
5b6ebf8f12
Add doctests to radix_sort() (#2148)
* Add doctests to radix_sort()

* fixup! Format Python code with psf/black push

* Update radix_sort.py

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-06-23 15:37:24 +02:00
mateuszz0000
d7a75da8ef
Added doctests to bucket sort (#2079)
* Added doctests to bucket sort

* Missing typehint

* Wrap long lines

* updating DIRECTORY.md

* Update bucket_sort.py

* updating DIRECTORY.md

* Update bucket_sort.py

Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-06-17 09:42:44 +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
mateuszz0000
6752e9c737
Remove boilerplate comments and unused variables (#2073) 2020-06-07 23:05:22 +02:00
mateuszz0000
20b21e5ec9
Refactor cycle_sort (#2072)
* Refactor cycle_sort

* Undo changes to keep only doctests
2020-06-05 09:13:43 +02:00
mateuszz0000
b080a5e027
Doctests + typehints in cocktail shaker sort (#2061)
* Doctests in cocktail shaker sort

* import doctest

* print(f"{cocktail_shaker_sort(unsorted) = }")

Co-authored-by: John Law <johnlaw.po@gmail.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2020-06-02 11:51:22 +02:00
KDH
4768735668
Enhance shell sort syntax (#2035) 2020-05-26 04:18:03 +02:00
mateuszz0000
a15f82579d
Added bead sort (#2022)
* Added bead sort

* Commit suggestion

* Added checking before sort

* Bead sort only works for sequences of nonegative integers

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-05-22 09:41:40 +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
Erwin Lejeune
21ed8968c0
Fixes in Bidirectional A* (#2020)
* implement bidirectional astar

* add type hints

* add wikipedia url

* format with black

* changes from review

* fix collision check

* Add testmod()

* # doctest: +NORMALIZE_WHITESPACE

* Codespell: euclidean

* Codespell: coordinates

* Codespell: traversal

* Codespell: remaining

Co-authored-by: John Law <johnlaw.po@gmail.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2020-05-21 21:50:52 +02:00
mateuszz0000
bc8e8f03fd
Added strand sort (#1982)
* Added strand sort

* Review changes

* Remove boilerplate code

* Fixed flake error: E252

* Added missing return type hint
2020-05-17 22:48:39 +02:00
Aman Gupta
ba8b156fdc
Iterative merge sort implementation (#1972)
* Added Iterative merge sort

* Added iterative merge sorts

* Update changes

* Add the ability to sort strings

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-05-11 16:40:02 +02:00
Maxim R
369562a1e8
Upgrades to caesar_cipher.py (#1958)
* Added more flexibility to functions, decreased amount of repeating code

* Added docstrings

* Updated input functions

* Added doctests

* removed test piece of code

* black .

* Updated caesar cipher standard alphabet to fit python 3.8

* Update and rename sleepsort.py to sleep_sort.py

* Or 4

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-05-08 07:44:07 +02:00
Arvind Krishna
9e5f365fed
Add sleep-sort (#1867)
* added sleepsort

Adding sleepsort

* Add doctest and typing for sleepsort

* Use self-descriptive variable name

* Update sleepsort.py

* Update sorts/sleepsort.py

Co-authored-by: John Law <johnlaw.po@gmail.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2020-05-07 21:44:34 +02:00
Christian Clauss
b1377f0e57
autoblack: actions/checkout@v1 # Use v1, NOT v2 (#1796)
* autoblack: actions/checkout@v1  # Use v1, NOT v2

* fixup! Format Python code with psf/black push

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-03-13 09:23:38 +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
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
Christian Clauss
b492e64417 Create pull_request_template.md (#1684)
* Create pull_request_template.md

* fixup! Format Python code with psf/black push

* Update pull_request_template.md

* updating DIRECTORY.md

* Update pull_request_template.md

* Update pull_request_template.md

* Update pull_request_template.md

* Update pull_request_template.md

* Update pull_request_template.md

* Typos and formatting

Co-authored-by: John Law <johnlaw.po@gmail.com>
2020-01-14 02:56:06 +08:00
shrabian
75523f9c1a A recursive insertion sort (#1683)
* A recursive insertion sort

* added doctests and typehints
2020-01-13 21:52:18 +05:30
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
harsh patel
d4fc55c5fc Add files via upload (#1657) 2020-01-04 16:03:55 +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
Samarth Sehgal
02b717e364 Update odd_even_transposition_parallel.py (#1458)
* Update odd_even_transposition_parallel.py

* arr = OddEvenTransposition(arr)
2019-12-08 23:43:56 +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
SHAKTI SINGH
ccc1ff2ce8 pigeonhole sorting in python (#364)
* pigeonhole sorting in python

* variable name update in pigeonhole_sort.py

* Add doctest
2019-12-06 07:34:21 +01:00
Bardia Alavi
494fb4fb49 address merge_soft duplicate files (#1612)
Here the old file merge_sort_fastest is renamed to unknown_sort. Because it is not merge sort algorithm.

Comments are updated accordingly.
2019-12-05 05:06:41 +01:00
Metehan
62e51fe487 recursive quick sort (#1536)
* recursive quick sort

* recursive quick sort

* Delete recursive-quick-sort

* Update recursive-quick-sort.py
2019-10-31 19:49:25 +01: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
anubhav-sharma13
ce7faa5a3a Largest subarray sum (#1404)
* Insertion_sort

* largest subarray sum

* updated print command

* removed extraspaces

* removed sys.maxint

* added explaination

* Updated function style

* Update largest_subarray_sum.py

* Update i_sort.py

* Delete bogo_bogo_sort.py
2019-10-22 09:30:11 +02:00
Sujitkumar Singh
38d7e7073a The time complexity of every algorithms make its value (#1401)
* added timer in bubble sort

* Updated time of execution

* import time in main only

* Update bubble_sort.py

* start = time.process_time()
2019-10-19 22:12:54 +02:00
ayush246
ab65a3915c Double sort (Added with required updates) (#1399)
* Added with required updates

* Updated

* required updates

* Update double_sort.py

* Update double_sort.py
2019-10-19 12:38:15 +02:00
Phyllipe Bezerra
455509acee Add Topological Sort (#1302)
* add topological sort

* fix topological sort?

* running black

* renaming file
2019-10-18 08:13:58 +02:00
Du YuanChao
e80d248e65 optimization (#1303) 2019-10-08 13:25:00 +05:00
mvhb
067a9b5136 adding input option and increasing the number of doctest (#1281)
* adding input option and incresing the number of doctest

* mixing positive and negative numbers in the same test case
2019-10-06 23:55:55 +05:00
William Zhang
9eac17a408 psf/black code formatting (#1277) 2019-10-05 10:14:13 +05:00
William Zhang
0e333ae021 added bogobogosort (#1258)
* added bogobogosort

* fix indentation error
2019-10-03 11:17:30 +02:00
Parth Paradkar
390feb0b23 Add doctests for sorting algorithms (#1263)
* doctests and intro docstring added

* doctests, docstrings and check for empty collection added

* Intro docstring added

* python versions reversed
2019-10-03 10:19:11 +02:00
Charitoc
2375bfbee5 Adding stooge sort (#1206)
* Adding stooge sort

* Updated doctest

* Just added underscore in the name
2019-09-26 17:19:01 +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
FrogBattle
e58a5e6842 Update tim_sort.py (#972)
* Update tim_sort.py


Update tim_sort.py

The previous algorithm was skipping numbers, according to issue #959, and my own tests.
The version I am applying uses a while loop, which works correctly and is easier to compute, as there is no break statement.

* Update tim_sort.py
2019-07-30 18:06:48 +02:00
obelisk0114
1dc9ec8fb2 Update Bucket Sort time complexity analysis (#918) 2019-07-12 23:16:14 +08:00
Alfonso Rodríguez Pereira
5f991f7740 #315 Renamed all files to snake_case (#993) 2019-07-11 11:16:42 +02:00
cclauss
b7f13d991c Travis CI: Run black, doctest, flake8, mypy, and pytest (#964)
* Travis CI: Add type checking with mypy

* Create requirements.txt

* script: mypy --ignore-missing-stubs=cv2,numpy .

* Delete requirements.txt

* script: mypy --ignore-missing-imports .

* Run doctests

* Disable doctest -v other/detecting_english_programmatically.py

* Pytest

* No |

* pytest || true

* Run black doctest flake8 mypy pytest

* after_success: Build Directory.md

* Typo in filename: Dictionary.txt --> dictionary.txt'

Discovered via doctest run in #964

* python -m doctest -v

* pip install black flake8 mypy pytest

* pytest --doctest-glob='*.py'

* pytest --doctest-modules

* pytest --doctest-modules ./sorts

* pytest --doctest-modules ./ciphers ./other ./searches ./sorts ./strings || true

* if __name__ == "__main__":

* if __name__ == "__main__":

* if __name__ == '__main__':

* if __name__ == '__main__':

* if __name__ == '__main__':

* Create requirements.txt

* Update requirements.txt

* if __name__ == "__main__":

* Lose the doctests

* if __name__ == '__main__':

* Remove print-a-tuple

* doctest: Added missing spaces

* Update tabu_search.py

* The >>> are not doctests so change to >>)

* Travis CI: Run black, doctest, flake8, mypy, and pytest

* Link to the separate DIRECTORY.md file

* Update README.md
2019-07-08 23:27:51 +08:00
Anup Kumar Panwar
4e413c0183 Updated README 2019-07-06 11:11:20 +05:30
PatOnTheBack
217615abf6 Removed Unused Variables (#949)
- Removed two unused variables.
- Changed `a` to `_` since the `a` variable is never used.

This addresses [3 alerts from lgtm](d55bbcd204/files/sorts/Odd-Even_transposition_parallel.py).
2019-07-05 14:04:46 +05:30
Ashok Bakthavathsalam
03f9940775 Refactored to one pop() (#917) 2019-07-03 23:31:10 +08:00
PatOnTheBack
a2236cfb97 Improve Formatting and Code Quality (#934)
* Improved Formatting of basic_maths.py

- Added docstrings.
- Improved whitespace formatting.
- Renamed functions to match snake_case.

* Improved Formatting of factorial_python.py

- Added docstrings.
- Improved whitespace formatting.
- Renamed constants to match UPPER_CASE.

* Improved Formatting of factorial_recursive.py

- Improved whitespace formatting to meet PyLint standards.

* Improved Code to Conform to PyLint

- Renamed `max` to `max_num` to avoid redefining built-in 'max' [pylint]
- Removed unnecessary parens after 'while' keyword [pylint]

* Improved Formatting of factorial_recursive.py

- Added docstrings.
- Improved whitespace formatting.
2019-07-02 09:35:43 +05:30
PatOnTheBack
bd4017928e Added Whitespace and Docstring (#924)
* Added Whitespace and Docstring

I modified the file to make Pylint happier and make the code more readable.

* Beautified Code and Added Docstring

I modified the file to make Pylint happier and make the code more readable.

* Added DOCSTRINGS, Wikipedia link, and whitespace

I added DOCSTRINGS and whitespace to make the code more readable and understandable.

* Improved Formatting

* Wrapped comments
* Fixed spelling error for `movement` variable
* Added DOCSTRINGs

* Improved Formatting

* Corrected whitespace to improve readability.
* Added docstrings.
* Made comments fit inside an 80 column layout.
2019-07-01 16:10:18 +08:00
BruceLee569
34889fc6d8 Update quick_sort.py (#928)
Use the last element as the first pivot, for it's easy to pop, this saves one element space.
Iterating with the original list saves half the space, instead of generate a new shallow copy list by slice method.
2019-06-28 23:55:31 +08:00
CharlesRitter
6e894ba3e8 Odd-Even Transposition Sort (#769)
* -Added a single-threaded implementation of odd-even transposition sort.

This is a modified bubble sort meant to work with multiple processors.
Since this is running on a single thread, it has the same running time
as bubble sort.

* -Added a parallel implementation of Odd-Even Transposition sort

This implementation uses multiprocessing to perform the swaps
at each step of the algorithm simultaneously.
2019-06-07 23:38:43 +08:00
Anup Kumar Panwar
71be23999c refactor 2019-05-26 21:56:10 +05:30
Mehdi ALAOUI
02c0daf9e5 Adding unit tests for sorting functions, and improving readability on some sorting algorithms (#784)
* Adding variable to fade out ambiguity

* More readability on merge sorting algorithm

* Updating merge_sort_fastest description and explaining why

* Adding tests file with imports

* Standardazing filenames and function names

* Adding test cases and test functions

* Adding test loop

* Putting 'user oriented code' inside main condition for having valid imports

* Fixing condition

* Updating tests: adding cases and todo list

* Refactoring first euler problem's first solution
2019-05-25 21:41:24 +08:00
José Henrique Ivanchechen
9f982a83c8 add pigeon hole sort (#833) 2019-05-24 22:46:39 +05:30
BruceLee569
a0ab3ce098 Update quick_sort.py (#830)
Modify the list comprehensions to reduce the number of judgments, the speed has increased by more than 50%.
2019-05-24 23:54:03 +08:00
Níkolas Vargas
023f5e092d fix empty list validation and code data structures (#826)
* fix empty list validation and code data structures

* Update bucket_sort.py

https://github.com/TheAlgorithms/Python/pull/826#pullrequestreview-240357549
2019-05-22 20:09:36 +08:00