Commit Graph
29 Commits
Author SHA1 Message Date
Ali Satwat KhanandChristian Clauss 948d4cb01e Improve docstrings in sorts/bubble_sort.py (#14924)
* docs: expand bubble sort docstrings with algorithm explanation

Add a concise description of how bubble sort works (repeated
adjacent comparisons/swaps until a pass makes no swaps) and note
time/space complexity for both the iterative and recursive
implementations. No behavior changes; all existing doctests pass.

* Fix Ruff 0.16 lint failures

* S310

---------

Co-authored-by: Christian Clauss <cclauss@me.com>
2026-07-30 20:29:25 -04:00
ADDALA MATHEWandMaxim Smolskiy 32a3d0d0bb Fix doctest bug in bubble_sort_recursive - incorrect function call (#13821)
Fixed bug in bubble_sort_recursive docstring where the doctest was calling bubble_sort_iterative([]) instead of bubble_sort_recursive([]). This was a copy-paste error that would cause the doctest to pass even if bubble_sort_recursive had issues with empty lists.

Change:
- Line 71: Changed '>>> bubble_sort_iterative([])' to '>>> bubble_sort_recursive([])'

This ensures the doctest properly validates the recursive implementation.

Co-authored-by: Maxim Smolskiy <mithridatus@mail.ru>
2026-03-09 20:28:01 +03:00
Parth PawarandMaxim Smolskiy 589d12972d Fix return type description in bubble_sort.py (#14137)
* Fix return type description in bubble_sort.py

Better (clearer, standard phrasing):
:return: the same collection ordered in ascending order

* Update bubble_sort.py

---------

Co-authored-by: Maxim Smolskiy <mithridatus@mail.ru>
2026-03-09 08:33:34 +03:00
radhikaRM06andMaxim Smolskiy 6da02abdce Add doctests for duplicate and sorted inputs in bubble sort (#14154)
Co-authored-by: Maxim Smolskiy <mithridatus@mail.ru>
2026-03-09 08:22:38 +03:00
Vijayalaxmi Wakodepre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>vijayalaxmi777Maxim Smolskiy
c666db3729 Add Doc test bubble sort (#12070)
* The string manipulation - replace()

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

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

* Update replace.py

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

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

* updating DIRECTORY.md

* Add doc test to bubble_sort

* Update DIRECTORY.md

* Delete strings/replace.py

* Update bubble_sort.py

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: vijayalaxmi777 <vijayalaxmi777@users.noreply.github.com>
Co-authored-by: Maxim Smolskiy <mithridatus@mail.ru>
2025-01-24 01:01:47 +03:00
Adam RossChristian Clausspre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
9875f374f4 Consolidate bubble sort iterative and recursive (#10651)
* Consolidate bubble sort iterative and recursive

* Update sorts/bubble_sort.py

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

* Refactor bubble sort func signature, doctest, timer

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

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

* Update bubble_sort.py

---------

Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2023-10-19 22:45:51 +02:00
Dylan Buchi 90a8e6e0d2 Update sorts/bubble_sort.py (#5802)
* Add missing type annotations in bubble_sort.py

* Refactor bubble_sort function
2023-07-31 11:50:00 -07:00
samyakpagariyaCaeden Perelli-Harrispre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>Christian Clauss
fcfe35c3d8 For the better understanding of time taken. (#6583)
* For the better understanding of time taken.

In this change I have initialized a variable p with the value of (1e9+7) and then took the modulus of process time with it . This modification gives better time taken by the process . Firstly it was giving answer in the exponential now it gives in the integer form.

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

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

* Apply suggestions from code review

Co-authored-by: Caeden Perelli-Harris <caedenperelliharris@gmail.com>

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: Caeden Perelli-Harris <caedenperelliharris@gmail.com>
2022-10-30 11:43:41 +01:00
Du Yuanchao 9b3f7c36d0 Test random input for bubble sort (#2492) 2020-10-02 13:55:58 +08: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
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
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
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
Ishmeet-Singh-Saggu ce0a013ad7 Update bubble_sort.py (#535) 2018-10-27 13:21:44 +02:00
Yasir Choudhary 9561259285 Merge branch 'master' into improved_sorting_algo 2018-10-19 12:05:26 +05:30
Harshil f9f5d402d3 Update bubble_sort.py
Added main method, Made it Python2 suitable, Enabled user input!
2018-10-16 20:39:22 +02:00
YasirChoudhary 6a6349bdb0 Optimised for loop iteration 2018-10-07 14:32:48 +05:30
Prateek 356b51458d done 2018-10-05 14:20:19 +05:30
Hossam Al-Dokkani 9489e8512d Break if the collection is sorted 2018-06-23 17:01:06 +02:00
Harshil 1611f40c51 Merge branch 'master' into revert-22-patch-1 2018-01-20 16:27:17 +05:30
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
Akshay Sharma 9deae5d14c PEP style and tree traversals 2016-09-26 02:45:14 +05:30
phlai 119da45c52 for better bubble sort 2016-09-11 17:51:34 +08:00
Anup Kumar Panwar a04d5c5e1e Revert "Update bubble_sort.py" 2016-08-26 17:16:03 +05:30
yyeltsyn ab8340cac7 Update bubble_sort.py 2016-08-26 09:02:54 +03:00
JakeBonek e359b6efd4 Fixed typos and added the shell sort algorithm 2016-08-16 12:43:02 -04:00
Sergey Tsaplin ab2614574e Move files to separate directories 2016-08-01 15:06:53 +05:00