SORT-P2

Merge sort

Practice 2 of 6Sorting7 tests

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

  1. Hint 1Nudge
  2. Hint 2Approach Open hint 1 first
  3. Hint 3Pseudocode Open hint 2 first
  4. Worked solutionlast resort Opens after all 3 hints
Python waits for a wider screensolution.py

Ctrl + Enter runs the tests. Tab indents; press Esc, then Tab, to leave the editor.

7 tests, not run yet
Test results
#TestResultReads · time
1Eight valuesNot run
2Odd lengthNot run
3RepeatsNot run
4Empty and oneNot run
5Negative valuesNot run
6Input not changedNot run
7100,000 valuesNot run