← Back to Data Structures & Algorithms
Question 540
Bubble Sort
Bubble Sort
Complete bubble_sort(values: list[int]) -> None, which sorts the list in place: the two loop headers are given, and on every step of the inner loop you compare values[j] with its right-hand neighbour values[j + 1] and swap them through a temp variable when the left one is bigger, so the largest value bubbles to the end of each pass. Bubble sort is O(n squared). Do NOT write a main block or any top-level test code; the tests construct the calls. Input: one line of space-separated integers; the tests call your function and then print the list.
Expected Output:
[1, 2, 4, 5, 8]= newline. The output ends with a newline — print one after the last line.
Hints3 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.