Implementation (Part 1)
Lesson 5 of 9 in Coddy's Selection Sort - DSA Series course.
Now, we will build the algorithm step by step.
Challenge
EasyLet's build Selection Sort one step at a time. The core move of the algorithm is to find the smallest element and swap it to the front.
Write a function named selectionSort that receives an array of integers, finds the smallest element, swaps it with the element at the first position, and returns the array.
For now you only need this single pass (one swap). The full algorithm comes in the next lesson.
Try it yourself
#include <stdlib.h>
int* selectionSort(int* arr, int arr_size, int* returnSize) {
// Write code here
*returnSize = arr_size;
return arr;
}
This lesson includes a short quiz. Start the lesson to answer it and track your progress.
All lessons in Selection Sort - DSA Series
2The Algorithm
How it works?Pseudo CodeImplementation (Part 1)Implementation (Part 2)