Menu
Coddy logo textTech

Implementation (Part 2)

Lesson 6 of 9 in Coddy's Quick Sort - DSA Series course.

Now we combine the pivot, partition, and recursion into the full algorithm.

challenge icon

Challenge

Easy

Now put it all together into the full algorithm.

Write a function named quickSort that takes an integer array and returns it sorted in ascending order.

Use the last element as the pivot, partition the rest into a smaller group and a larger group, recursively quickSort each group, and combine them as sorted-smaller + pivot + sorted-larger. An array with 0 or 1 elements is already sorted, so return it as is.

You can reuse the partition idea from the previous lesson.

Try it yourself

#include <stdlib.h>

int* quickSort(int* arr, int arr_size, int* returnSize) {
    // Write code here
    *returnSize = arr_size;
    return arr;
}
quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Quick Sort - DSA Series