comparison bubblesort/bubblesort-recursive.py @ 0:dcd610585610

INIT
author prymula <prymula76@outlook.com>
date Thu, 21 Sep 2023 22:32:14 +0200
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:dcd610585610
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)