def bubble_sort(fiston):
n = len(fiston)
for i in range(n):
for j in range(0, n - i - 1):
if fiston[j] > fiston[j + 1]:
fiston[j], fiston[j + 1] = fiston[j + 1], fiston[j]
return fiston
# Ejemplo de uso
datos = ["Juan", "Pedro", "María", "Ana", "Luis", "Elena", "José"]
print("Burbuja:", bubble_sort(datos.copy()))
def selection_sort(fiston):
n = len(fiston)
for i in range(n):
min_idx = i
for j in range(i + 1, n):
if fiston[j] < fiston[min_idx]:
min_idx = j
fiston[i], fiston[min_idx] = fiston[min_idx], fiston[i]
return fiston
# Ejemplo de uso
datos = ["Carlos", "Sofía", "Miguel", "Valeria", "Andrés", "Fernanda", "Diego"]
print("Selección:", selection_sort(datos.copy()))
def insertion_sort(fiston):
for i in range(1, len(fiston)):
clave = fiston[i]
j = i - 1
while j >= 0 and clave < fiston[j]:
fiston[j + 1] = fiston[j]
j -= 1
fiston[j + 1] = clave
return fiston
# Ejemplo de uso
datos = [48, 17, 63, 9, 35, 22, 54]
print("Inserción:", insertion_sort(datos.copy()))
To embed this project on your website, copy the following code and paste it into your website's HTML: