The problem
Write merge sort. Return a new sorted list, and leave a unchanged. sorted() and .sort() are switched off.
merge_sort([38, 27, 43, 3, 9, 82, 10, 15])
# [3, 9, 10, 15, 27, 38, 43, 82]
merge_sort([]) # []
Limits
- Up to 100,000 whole numbers, in any order.
Builds on SORT-2 Merge sort.
Continue on a laptop
Practice runs Python in the browser and needs a keyboard and a wider screen. Read the problem and open hints here, then write your solution on a laptop. Progress is saved per browser for now, so hints opened here stay on this device.
Need a hint?0 of 3 opened
- Hint 1Nudge
- Hint 2Approach Open hint 1 first
- Hint 3Pseudocode Open hint 2 first
- Worked solutionlast resort Opens after all 3 hints
Ctrl + Enter runs the tests. Tab indents; press Esc, then Tab, to leave the editor.
7 tests, not run yet
| # | Test | Result | Reads · time |
|---|---|---|---|
| 1 | Eight values | Not run | |
| 2 | Odd length | Not run | |
| 3 | Repeats | Not run | |
| 4 | Empty and one | Not run | |
| 5 | Negative values | Not run | |
| 6 | Input not changed | Not run | |
| 7 | 100,000 values | Not run |