Mercurial > hg > pub > prymula > scripts
annotate bubblesort/bubblesort-recursive.py @ 40:a2ac31358aba default tip
READEM FIX
author | prymula <prymula76@outlook.com> |
---|---|
date | Sat, 10 Feb 2024 22:37:08 +0100 |
parents | dcd610585610 |
children |
rev | line source |
---|---|
0 | 1 #!/usr/bin/env python3 |
2 | |
3 tab = [3, 10, 1, 4, 5, 9, 8, 20, 11, 15, 12, 17, 18] | |
4 | |
5 def func1(i): | |
6 if i == 0: | |
7 return | |
8 else: | |
9 func2(len(tab) - i - 1) | |
10 #print("i: "+str(i)) | |
11 func1(i - 1) | |
12 | |
13 def func2(j): | |
14 if j < 0: | |
15 return | |
16 else: | |
17 if (tab[j] > tab[j + 1]): | |
18 tab[j], tab[j+ 1] = tab[j + 1], tab[j] | |
19 #print ("j:"+str(j)) | |
20 func2(j - 1) | |
21 | |
22 func1(len(tab)) | |
23 print(tab) |