Open
Conversation
|
Pas mal |
bcalou
reviewed
Nov 24, 2023
Comment on lines
+8
to
+16
| for i in range(len(array)): | ||
| min_index: int = i | ||
| # Find the index of the smallest element | ||
| # in the unsorted part of the array | ||
| for j in range(i + 1, len(array)): | ||
| if array[j] < array[min_index]: | ||
| min_index = j | ||
| # Swap the smallest element with the first element of the unsorted part | ||
| array[i], array[min_index] = array[min_index], array[i] |
Owner
There was a problem hiding this comment.
Bien, juste ajouter quelques lignes vides (par exemple avant les commentaires)
sort/recursion.py
Outdated
Comment on lines
+8
to
+10
| if number == 0: | ||
| return 1 | ||
| return number * get_factorial(number - 1) |
sort/insertion.py
Outdated
Comment on lines
+11
to
+13
| while j >= 0 and key < array[j]: | ||
| array[j + 1] = array[j] | ||
| j -= 1 |
Owner
There was a problem hiding this comment.
Tu modifies le tableau à chaque itération. On peut le modifier une seule fois, après avoir trouvé le bon index.
sort/insertion.py
Outdated
| :return: The sorted array. | ||
| """ | ||
| for i in range(1, len(array)): | ||
| key: int = array[i] |
sort/fusion.py
Outdated
| @@ -1,2 +1,43 @@ | |||
| def merge(left: list[int], right: list[int]) -> list[int]: | |||
Owner
There was a problem hiding this comment.
Conserver l'ordre d'appel des fonctions (sort au début du fichier)
Owner
|
Très bien, très clair. Il y a juste le code de l'insertion qui est dépourvu de commentaires, donc pas simple à suivre. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.