Skip to main content
Practice

coding-quiz-3

---
id: coding-quiz-3
title: Coding Quiz - Sort a List Using Merge Sort
description: Create a function to sort a list of numbers in ascending order using the merge sort algorithm.
tags:
- Coding Quiz
- Merge Sort
- Python
sidebar_position: 13
isPublic: false
---

# 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.

<br />

```python title="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]

Want to learn more?

Join CodeFriends Plus membership or enroll in a course to start your journey.