0
I’m starting studies and I’m studying the book I understand the algorithms and in cap 2 I don’t understand this algorithm.
Here in case is to find the lowest value of an element.
def buscaMenor(arr):
menor = arr[0]
menor_indice = 0
for i in range(1, len(arr)):
if arr[i] < menor:
menor = arr[i]
menor_indice = i
return menor_indice
def ordenacaoporselecao(arr):
novoArr = []
for i in range(len(arr)):
menor = buscaMenor(arr)
novoArr.append(arr.pop(menor))
return novoArr
print ordenacaoporselecao([5, 3, 6, 2, 10])
here in my understanding I thought I would order the items.
could help me understand these codes and if you have tips or suggestions to learn the algorithms ?
Thank you, I thought when you printed it he would order from the smallest to the greatest
– Igor Magalhães