#Pseudocode a Sorting Algorithm
Algorithms are fundamental to coding and sorting is fundamental to algorithms. In this exercise, we're going to implement a simple sorting algorithm using pseudocode. With pseudocode, there is no such thing as invalid syntax. But remember! Every line of your "code" should be able to translate into a single, direct programming statement.
Input: An unsorted array of n numbers
Output: A sorted (least to greatest) array n of numbers
Description:
-
Start at the end of the list and get the last element: A[n]
-
Compare that element to the one before it. A[n-1]
-
If A[n] < A[n-1] , then swap the two elements
-
Repeat this step until the first element, A[0] is the smallest
-
Start back at the end, A[n] and repeat until the entire array is sorted
Hint: If you're having trouble visualizing how this algorithm works, just imagine the elements bubbling up from the bottom until they're all in order.