← Back to Data Structures & Algorithms
Question 562
Selection Sort
Selection Sort
Write selection_sort(values: list[int]) -> None that sorts the list in place: for each position i from the front, find the index smallest of the least value from i to the end with an inner loop, then swap the values at i and smallest through a temp variable. The inner loop scans the whole unsorted part every time, so this is O(n squared) even on sorted input. Do NOT write a main block or any top-level test code; the tests construct the calls. Input: one line of space-separated integers (possibly empty); the tests call your function and then print the list.
Expected Output:
[11, 12, 22, 25, 64]= newline. The output ends with a newline — print one after the last line.
Hints4 available
Sign in to use hintsTopics:
Data Structures & AlgorithmsBig-O
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Ctrl+Space to expand shortcuts (pr, inp, def)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.