Conversation
sort/selection.py
Outdated
| smallest_number: int = array[number_of_sorted_numbers] | ||
| smallest_number_index: int = number_of_sorted_numbers |
There was a problem hiding this comment.
Pourquoi ne pas stocker uniquement l'index ? Le code sera un peu plus simple
sort/insertion.py
Outdated
| for index in range(1, len(array)): | ||
| number: int = array[index] | ||
| # on parcours la partie trié du tableau dans le sens décroissant | ||
| for sorted_numberIndex in reversed(range(0, number_of_sorted_numbers)): |
sort/insertion.py
Outdated
| if number < sorted_number: | ||
| array.insert(sorted_numberIndex, number) | ||
| else: | ||
| array.insert(sorted_numberIndex+1, number) |
There was a problem hiding this comment.
Ça marche mais ce n'est pas tout à fait satisfaisant, ce +1 conditionnel. Trouver une autre approche ? Je pinaille...
sort/fusion.py
Outdated
| # Le deuxième tableau peut être vide si le tableau original | ||
| # a une taille impaire | ||
| if array2 == []: | ||
| return array1 |
There was a problem hiding this comment.
En es-tu sûr ? Pas d'après ce que je lis dans sort.
sort/fusion.py
Outdated
| if index1 >= size1 and index2 < size2: | ||
| sorted_array.append(array2[index2]) | ||
| index2 += 1 | ||
| continue | ||
| elif index2 >= size2 and index1 < size1: | ||
| sorted_array.append(array1[index1]) | ||
| index1 += 1 | ||
| continue |
There was a problem hiding this comment.
Ça marche mais ça veut dire qu'on va ajouter tous les éléments restant un par un, itération après itération. On ne peut pas faire plus direct ?
|
C'est très bien, avec un bémol cette fois-ci sur la quantité de commentaires : il faut tout à fait en mettre, mais attention à ne pas noyer le code non plus et à rester pertinent. C'est un équilibre à trouver. Si le code se suffit à lui-même, on peut parfois en retier un peu. |
No description provided.