File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22
33
44def 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
6365def 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
You can’t perform that action at this time.
0 commit comments