Commit Graph

22 Commits

Author SHA1 Message Date
Tushar Pamnani
7b9f82cc44
optimize quicksort implementation (#11196)
* optimize quicksort implementation

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Apply suggestions from code review

* Update quick_sort.py

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Tianyi Zheng <tianyizheng02@gmail.com>
2023-12-19 20:59:51 -05:00
Christian Clauss
64543faa98
Make some ruff fixes (#8154)
* Make some ruff fixes

* Undo manual fix

* Undo manual fix

* Updates from ruff=0.0.251
2023-03-01 17:23:33 +01:00
Jérome Eertmans
8cce0d463a
refactor: pivot is randomly chosen (#6643)
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
2022-10-05 11:32:07 +01: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
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
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
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
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
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
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
sakuralethe
48553da785 variable in function should be lowercase (#768) 2019-04-26 17:43:51 +08:00
cclauss
4e06949072 Modernize Python 2 code to get ready for Python 3 2017-11-25 10:23:50 +01:00
KyleScharnhorst
014786e340 Fix: typo in multiple files. 2017-10-07 06:47:50 -07:00
Mehdi ALAOUI
7ae9759220 Added some other spaces 2017-04-06 03:55:28 +01:00
Mehdi ALAOUI
8d06eb2c63 Added some space before and after operators 2017-04-06 03:44:47 +01:00
Mehdi ALAOUI
183df6889b Code more concise and more readable 2017-04-05 06:58:16 +01:00
alvin562
839a84182c updated version 2017-01-03 00:08:42 -08:00
yyeltsyn
66433a5f0b Update quick_sort.py
Streamlining quick_sort function
2016-08-29 11:29:49 +03:00
JakeBonek
e359b6efd4 Fixed typos and added the shell sort algorithm 2016-08-16 12:43:02 -04:00
miczal
78402c5f42 [Quicksort]Added shuffling of input 2016-08-11 20:02:06 +02:00
Sergey Tsaplin
ab2614574e Move files to separate directories 2016-08-01 15:06:53 +05:00