This website works better with JavaScript.
Home
Explore
Help
Sign In
jrtechs
/
jrtechs-RandomScripts
mirror of
https://github.com/jrtechs/RandomScripts.git
Watch
1
Star
0
Fork
0
Code
Issues
0
Releases
0
Wiki
Activity
Browse Source
Merge pull request
#1
from sunny3p/sortalgos
Sortalgos
pull/4/head
Sunny Patel
6 years ago
committed by
GitHub
parent
5dad3b7df5
5cfce3ba4c
commit
630496773f
No known key found for this signature in database
GPG Key ID:
4AEE18F83AFDEB23
3 changed files
with
39 additions
and
0 deletions
Split View
Diff Options
Show Stats
Download Patch File
Download Diff File
BIN
.DS_Store
+17
-0
sorting/BubbleSort.py
+22
-0
sorting/QuickBublesort.py
BIN
.DS_Store
View File
+ 17
- 0
sorting/BubbleSort.py
View File
@ -0,0 +1,17 @@
# coding: utf-8
# In[43]:
alist
=
[
54
,
26
,
93
,
17
,
77
,
31
,
44
,
55
,
20
]
def
bubbleSort
(
alist
)
:
for
passnum
in
range
(
len
(
alist
)
-
1
,
0
,
-
1
)
:
for
i
in
range
(
passnum
)
:
if
alist
[
i
]
>
alist
[
i
+
1
]
:
temp
=
alist
[
i
]
alist
[
i
]
=
alist
[
i
+
1
]
alist
[
i
+
1
]
=
temp
return
alist
print
(
bubbleSort
(
alist
)
)
+ 22
- 0
sorting/QuickBublesort.py
View File
@ -0,0 +1,22 @@
# coding: utf-8
# In[45]:
alist
=
[
54
,
26
,
93
,
17
,
77
,
31
,
44
,
55
,
20
]
def
shortBubbleSort
(
alist
)
:
exchanges
=
True
passnum
=
len
(
alist
)
-
1
while
passnum
>
0
and
exchanges
:
exchanges
=
False
for
i
in
range
(
passnum
)
:
if
alist
[
i
]
>
alist
[
i
+
1
]
:
exchanges
=
True
temp
=
alist
[
i
]
alist
[
i
]
=
alist
[
i
+
1
]
alist
[
i
+
1
]
=
temp
passnum
=
passnum
-
1
return
alist
print
(
shortBubbleSort
(
alist
)
)
Write
Preview
Loading…
Cancel
Save