Menu
Coddy logo textTech

Implementation (Part 1)

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

We will build Quick Sort from its core operation up.

challenge icon

Challenge

Easy

The heart of Quick Sort is the partition step. Let's build that first.

Write a function named partition that uses the last element of arr as the pivot and returns a new array with:

  • all elements less than the pivot (in their original order),
  • then the pivot,
  • then all remaining elements, those greater than or equal to the pivot (in their original order).

For example, [3, 7, 1, 8, 5] becomes [3, 1, 5, 7, 8] (pivot 5).

Try it yourself

#include <stdlib.h>

int* partition(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