Skip to content

Commit 85c369e

Browse files
author
deepshekhardas
committed
docs: improve bubble sort docstrings with algorithm summary
1 parent c0db072 commit 85c369e

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

sorts/bubble_sort.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33

44
def bubble_sort_iterative(collection: list[Any]) -> list[Any]:
5-
"""Pure implementation of bubble sort algorithm in Python
5+
"""Bubble sort algorithm that iteratively steps through the list,
6+
compares adjacent elements, and swaps them if they are in the wrong
7+
order. The process is repeated until the list is sorted.
68
79
:param collection: some mutable ordered collection with heterogeneous
810
comparable items inside
@@ -61,7 +63,10 @@ def bubble_sort_iterative(collection: list[Any]) -> list[Any]:
6163

6264

6365
def bubble_sort_recursive(collection: list[Any]) -> list[Any]:
64-
"""It is similar iterative bubble sort but recursive.
66+
"""Bubble sort algorithm that recursively steps through the list,
67+
compares adjacent elements, and swaps them if they are in the wrong
68+
order. Each recursion performs one full pass, bubbling the largest
69+
element to its correct position, then recurses on the remaining list.
6570
6671
:param collection: mutable ordered sequence of elements
6772
:return: the same list in ascending order

0 commit comments

Comments
 (0)