FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
python/algorithms/sorting/bubble_sort.py at master · AllAlgorithms/python · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
This repository was archived by the owner on Sep 7, 2025. It is now read-only.
AllAlgorithms
/
python
Public archive
Notifications
You must be signed in to change notification settings
Fork
170
Star
385
Code
Issues
1
Pull requests
19
Actions
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Security and quality
Insights
Expand file tree
Breadcrumbs
python
/
algorithms
/
sorting
/
bubble_sort.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
26 lines (20 loc) · 458 Bytes
Breadcrumbs
python
/
algorithms
/
sorting
/
bubble_sort.py
Copy path
File metadata and controls
26 lines (20 loc) · 458 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# Python implementation of bubble sort
#
# Author: Carlos Abraham Hernandez
def
bubbleSort
(
arr
):
n
=
len
(
arr
)
for
i
in
range
(
n
):
for
j
in
range
(
0
,
n
-
i
-
1
):
if
arr
[
j
]
>
arr
[
j
+
1
] :
arr
[
j
],
arr
[
j
+
1
]
=
arr
[
j
+
1
],
arr
[
j
]
def
printArray
(
arr
):
for
i
in
range
(
len
(
arr
)):
print
(
"%d"
%
arr
[
i
]),
# Test
arr
=
[
46
,
24
,
33
,
10
,
2
,
81
,
50
]
print
(
"Unsorted Array:"
)
printArray
(
arr
)
print
(
'
\n
'
)
bubbleSort
(
arr
)
print
(
"Sorted Array:"
)
printArray
(
arr
)
Back
|
FazBrowse Home
|
New Git URL