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]

Lecture

AI Tutor

Publish

Design

Upload

Notes

Favorites

Help