Challenge 3: Sort an Array
Given an array of numbers, sort it in increasing order.
We'll cover the following
Problem Statement
Implement a function that sorts the input array testVariable
in-place.
In-place means that no extra array or any other data structure is used. Such algorithms produce an output in the same memory/space that contains the data by transforming the input in-place
. However, a constant extra space can be used in the form of simple variables.
Remember to solve this problem recursively.
Input
- An array
testVariable
containing numbers. - Length of the array
Output
No output. Our task is to sort the input array.
Sample Input
testVariable = [5, 4, 2, 3, 1]
length = 5
Sample Output
# No explicit output.
# However the state of array testVariable is [1, 2, 3, 4, 5]
Try it Yourself
Try to attempt this challenge by yourself before moving on to the solution. Good luck!
def sort(testVariable, length) :# Write your code herereturn None
In the next lesson, we have the solution review of this problem.