Lecture
Coding Quiz - Sort a List Using Quick Sort
The challenge for this coding quiz is to implement the quick sort algorithm in Python.
You are tasked with writing a function that takes a list of arbitrary numbers as input, sorts it in ascending order using quick sort, and returns the sorted list.
Write Your Code
def solution(arr): # Write your code here return
Constraints
-
The input list will contain only numbers.
-
There are no restrictions on the size of the list.
-
You must use the standard implementation of quick sort (including pivot selection and partitioning).
Example Input/Output
-
Input:
[3, 6, 8, 10, 1, 2, 1] -
Output:
[1, 1, 2, 3, 6, 8, 10]
-
Input:
[3, 1, 4, 1, 5] -
Output:
[1, 1, 3, 4, 5]
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