Grokking the Art of Recursion for Coding Interviews
Vote

0% completed

Solution: Quick Sort

Problem Statement

Write Recursive Approach for Quick Sort

Given an array of integers, sort it in ascending order using the Quick Sort algorithm.

Examples

Sr#Input ArrayOutputDescription
1[4, 2, 6, 8, 3][2, 3, 4, 6, 8]The array is sorted in ascending order.
2[10, 5, 3, 7, 2, 8, 6][2, 3, 5, 6, 7, 8, 10]The array is sorted in ascending order.

.....

.....

.....

Like the course? Get enrolled and start learning!
Exanubes

Exanubes

· 2 years ago

How can the presented implementation be $O(logn)$ space complexity considering it creates several new arrays on each iteration and returns a new array as well?

Saumya Kumar

Saumya Kumar

· 6 months ago

This is not a in-place quicksort, but we can implement quick sort using the swapping instead of creating new lists.