Este site funciona melhor com JavaScript.
Página inicial
Explorar
Ajuda
Acessar
jrtechs
/
jrtechs-RandomScripts
espelhamento de
https://github.com/jrtechs/RandomScripts.git
Observar
1
Favorito
0
Fork
0
Código
Issues
0
Versões
0
Wiki
Atividade
Ver código fonte
QuickBubblesortwithgood complexity
pull/5/head
Sunny Pate
5 anos atrás
pai
72a1d835df
commit
5cfce3ba4c
2 arquivos alterados
com
22 adições
e
0 exclusões
Visão dividida
Opções de diferenças
Mostrar estatísticas
Baixar arquivo de patch
Baixar arquivo de diferenças
BIN
.DS_Store
+22
-0
sorting/QuickBublesort.py
BIN
.DS_Store
Ver arquivo
+ 22
- 0
sorting/QuickBublesort.py
Ver arquivo
@ -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
)
)
Escrever
Pré-visualização
Carregando…
Cancelar
Salvar