Skip to content

Commit fcc80a7

Browse files
authored
Merge pull request #305 from LucasMagnum/pelican
Post - Algoritmos de ordenação
2 parents c5fba1f + dc63e6a commit fcc80a7

File tree

1 file changed

+98
-0
lines changed

1 file changed

+98
-0
lines changed
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
Algoritmos de Ordenação
2+
########################
3+
4+
:date: 2018-11-20 23:10
5+
:tags: python, algoritmos
6+
:category: Python
7+
:slug: algoritmos-ordenacao
8+
:author: Lucas Magnum
9+
:email: lucasmagnumlopes@gmail.com
10+
:github: lucasmagnum
11+
:linkedin: lucasmagnum
12+
13+
Fala pessoal, tudo bom?
14+
15+
Nos vídeos abaixo, vamos aprender como implementar alguns dos algoritmos de ordenação usando Python.
16+
17+
18+
Bubble Sort
19+
===========
20+
21+
Como o algoritmo funciona: Como implementar o algoritmo usando Python: `https://www.youtube.com/watch?v=Doy64STkwlI <https://www.youtube.com/watch?v=Doy64STkwlI&list=PLvo_Yb_myrNBhIdq8qqtNSDFtnBfsKL2r&t=0s&index=3>`_.
22+
23+
24+
.. youtube:: Doy64STkwlI
25+
26+
Como implementar o algoritmo usando Python: `https://www.youtube.com/watch?v=B0DFF0fE4rk <https://www.youtube.com/watch?v=B0DFF0fE4rk&index=3&list=PLvo_Yb_myrNBhIdq8qqtNSDFtnBfsKL2r>`_.
27+
28+
.. youtube:: B0DFF0fE4rk
29+
30+
Código do algoritmo
31+
32+
.. code-block:: python
33+
34+
def sort(array):
35+
36+
for final in range(len(array), 0, -1):
37+
exchanging = False
38+
39+
for current in range(0, final - 1):
40+
if array[current] > array[current + 1]:
41+
array[current + 1], array[current] = array[current], array[current + 1]
42+
exchanging = True
43+
44+
if not exchanging:
45+
break
46+
47+
48+
Selection Sort
49+
==============
50+
51+
Como o algoritmo funciona: Como implementar o algoritmo usando Python: `https://www.youtube.com/watch?v=PLvo_Yb_myrNBhIdq8qqtNSDFtnBfsKL2r <https://www.youtube.com/watch?v=PLvo_Yb_myrNBhIdq8qqtNSDFtnBfsKL2r&list=PLvo_Yb_myrNBhIdq8qqtNSDFtnBfsKL2r&t=0s&index=4>`_.
52+
53+
54+
.. youtube:: PLvo_Yb_myrNBhIdq8qqtNSDFtnBfsKL2r
55+
56+
Como implementar o algoritmo usando Python: `https://www.youtube.com/watch?v=0ORfCwwhF_I <https://www.youtube.com/watch?v=0ORfCwwhF_I&index=5&list=PLvo_Yb_myrNBhIdq8qqtNSDFtnBfsKL2r>`_.
57+
58+
.. youtube:: 0ORfCwwhF_I
59+
60+
Código do algoritmo
61+
62+
.. code-block:: python
63+
64+
def sort(array):
65+
for index in range(0, len(array)):
66+
min_index = index
67+
68+
for right in range(index + 1, len(array)):
69+
if array[right] < array[min_index]:
70+
min_index = right
71+
72+
array[index], array[min_index] = array[min_index], array[index]
73+
74+
75+
Insertion Sort
76+
==============
77+
78+
Como o algoritmo funciona: Como implementar o algoritmo usando Python: `https://www.youtube.com/watch?v=O_E-Lj5HuRU <https://www.youtube.com/watch?v=O_E-Lj5HuRU&list=PLvo_Yb_myrNBhIdq8qqtNSDFtnBfsKL2r&t=0s&index=6>`_.
79+
80+
.. youtube:: O_E-Lj5HuRU
81+
82+
Como implementar o algoritmo usando Python: `https://www.youtube.com/watch?v=Sy_Z1pqMgko <https://www.youtube.com/watch?v=Sy_Z1pqMgko&index=7&list=PLvo_Yb_myrNBhIdq8qqtNSDFtnBfsKL2r>`_.
83+
84+
.. youtube:: Sy_Z1pqMgko
85+
86+
Código do algoritmo
87+
88+
.. code-block:: python
89+
90+
def sort(array):
91+
for p in range(0, len(array)):
92+
current_element = array[p]
93+
94+
while p > 0 and array[p - 1] > current_element:
95+
array[p] = array[p - 1]
96+
p -= 1
97+
98+
array[p] = current_element

0 commit comments

Comments
 (0)