File tree 2 files changed +34
-4
lines changed
2 files changed +34
-4
lines changed Original file line number Diff line number Diff line change @@ -2696,8 +2696,8 @@ Com o objetivo de alcançar uma abrangência maior e encorajar novas pessoas a c
2696
2696
</a>
2697
2697
</td>
2698
2698
<td> <!-- Python -->
2699
- <a href="./CONTRIBUTING.md ">
2700
- <img align="center" height="25" src="https://cdn.jsdelivr.net/gh/devicons/devicon/icons/github/github -original.svg" />
2699
+ <a href="./src/python/comb_sort.py ">
2700
+ <img align="center" height="25" src="https://cdn.jsdelivr.net/gh/devicons/devicon/icons/python/python -original.svg" />
2701
2701
</a>
2702
2702
</td>
2703
2703
<td> <!-- Go -->
@@ -2870,8 +2870,8 @@ Com o objetivo de alcançar uma abrangência maior e encorajar novas pessoas a c
2870
2870
</a>
2871
2871
</td>
2872
2872
<td> <!-- Python -->
2873
- <a href="./CONTRIBUTING.md ">
2874
- <img align="center" height="25" src="https://cdn.jsdelivr.net/gh/devicons/devicon/icons/github/github -original.svg" />
2873
+ <a href="./src/python/heap_sort.py ">
2874
+ <img align="center" height="25" src="https://cdn.jsdelivr.net/gh/devicons/devicon/icons/python/python -original.svg" />
2875
2875
</a>
2876
2876
</td>
2877
2877
<td> <!-- Go -->
Original file line number Diff line number Diff line change
1
+ #!/usr/bin/env python3
2
+ # -*- coding: utf-8 -*-
3
+ #----------------------------------------------------------------------------
4
+ # Created By : octaviolage
5
+ # Created Date: 2022-05-15
6
+ # version ='1.0'
7
+ # -------------------------------
8
+ def comb_sort (arr : list ) -> list :
9
+ """
10
+ Implementação de um algoritmo de ordenação combinada.
11
+ """
12
+ gap = len (arr )
13
+ shrink = 1.3
14
+ swapped = True
15
+ while gap > 1 or swapped :
16
+ gap = int (gap / shrink )
17
+ if gap < 1 :
18
+ gap = 1
19
+ swapped = False
20
+ for i in range (len (arr ) - gap ):
21
+ if arr [i ] > arr [i + gap ]:
22
+ arr [i ], arr [i + gap ] = arr [i + gap ], arr [i ]
23
+ swapped = True
24
+ return arr
25
+
26
+ if __name__ == '__main__' :
27
+ from random import randint
28
+ my_list = [randint (0 , 100 ) for _ in range (10 )]
29
+ print (f'Lista: { my_list } ' )
30
+ print (f'Ordenada: { comb_sort (my_list )} ' )
You can’t perform that action at this time.
0 commit comments