view bubblesort/bubblesort-recursive.py @ 7:d202f30cd362

verysimpleslideshow-0.230913-0_ALLDISTRIBUTION
author prymula <prymula76@outlook.com>
date Sat, 03 Feb 2024 19:06:00 +0100
parents dcd610585610
children
line wrap: on
line source

#!/usr/bin/env python3

tab = [3, 10, 1, 4, 5, 9, 8, 20, 11, 15, 12, 17, 18]

def func1(i):
	if i == 0:
		return
	else:
		func2(len(tab) - i - 1)
		#print("i: "+str(i))
		func1(i - 1)
		
def func2(j):
	if j < 0:
		return
	else:
		if (tab[j] > tab[j + 1]):
			tab[j], tab[j+ 1] = tab[j + 1], tab[j]
		#print ("j:"+str(j))
		func2(j - 1)
		
func1(len(tab))
print(tab)