Challenge: Implement Swap
Do you know how Swap Function works? Implement to prove yourself!
We'll cover the following
Swap Function
A key step in many sorting algorithms (including selection sort) is swapping the location of two items in an array. Here’s an Empty Function that needs to Swap the elements of a given array, as per the specified indices.
Coding Exercise
Take a close look and design a step-by-step algorithm first before jumping on implementation. This problem is designed for your practice, so try to solve it on your own first. If you get stuck, you can always refer to the solution provided in the solution section. Good Luck!
Create a free account to access the full course.
By signing up, you agree to Educative's Terms of Service and Privacy Policy