Mercurial > hg > pub > prymula > scripts
annotate bubblesort/bubblesort-recursive.py @ 2:4bdac9bd90cc
vsss-0.230913-0.1_PKG
author | prymula <prymula76@outlook.com> |
---|---|
date | Thu, 01 Feb 2024 17:13:37 +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) |