This website works better with JavaScript.
首頁
探索
說明
登入
jrtechs
/
jrtechs-RandomScripts
镜像来自
https://github.com/jrtechs/RandomScripts.git
關註
1
收藏
0
複製
0
程式碼
問題管理
0
版本發佈
0
Wiki
Activity
瀏覽代碼
QuickBubblesortwithgood complexity
pull/5/head
Sunny Pate
5 年之前
父節點
72a1d835df
當前提交
5cfce3ba4c
共有
2 個文件被更改
,包括
22 次插入
和
0 次删除
分割檢視
Diff Options
Show Stats
Download Patch File
Download Diff File
二進制
.DS_Store
+22
-0
sorting/QuickBublesort.py
二進制
.DS_Store
查看文件
+ 22
- 0
sorting/QuickBublesort.py
查看文件
@ -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…
取消
儲存