As described in #6095, this reduces the chances to observe a O(n^2) complexity.
Here, `collection.pop(pivot_index)` is avoided for performance reasons.
Fixes: #6095
* fixed wrong algo name to radix sort
* added wiki url
* Added "source" in docstring
* Update radix_sort.py
Co-authored-by: Christian Clauss <cclauss@me.com>
* Fixed bug where array length 2 can't be sorted
* Add MCC and DU path test
Add test to conversions/octal_to_decimal.py and sorts\iterative_merge_sort.py
* ""
* Update octal_to_decimal.py
Co-authored-by: John Law <johnlaw.po@gmail.com>
* 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>
* 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>
* 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
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>
* [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>
* 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>
* 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>
* Tighten up quicksort()
* updating DIRECTORY.md
* str does not support .pop()
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
* 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
* 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>
* 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>