Lecture
Coding Quiz - Sort a List Using Merge Sort
In this coding quiz, you will write a Python function to sort a given list using the merge sort algorithm.
Merge sort is a divide and conquer algorithm that splits the array in half, recursively sorts each half, and then merges the two halves to produce a fully sorted array.
Review what you've learned and try implementing the merge sort algorithm in Python.
Write Your Code
def solution(arr): # Write your code here return
Constraints
-
The array consists only of integers.
-
The array has at least one element.
-
The sorting should be done in ascending order.
Example Input/Output
-
Input:
[3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5] -
Output:
[1, 1, 2, 3, 3, 4, 5, 5, 5, 6, 9]
Lessons in this chapter · Practical Python Algorithms
- 1. Advanced Python Algorithms
- 2. What is a Recursive Call?
- 3. Implementing Fibonacci Sequence with Recursive Function
- 4. Fill-in-the-blank quiz
- 5. Coding Quiz - Fibonacci Sequence
- 6. Dynamic Programming and Divide and Conquer
- 7. Implementing Dynamic Programming in Python
- 8. Multiple-choice quiz
- 9. Coding Quiz - Make One
- 10. What is Merge Sort?
- 11. Implementing Merge Sort
- 12. Multiple-choice quiz
- 13. Coding Quiz - Sort a List Using Merge Sort
- 14. What is Quick Sort?
- 15. Implementing Quick Sort in Python
- 16. Multiple-choice quiz
- 17. Coding Quiz - Sort a List Using Quick Sort
Lecture
AI Tutor
Design
Upload
Notes
Favorites
Help