-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating
Fundamentals for Self-Taught Programmers
By :
In the previous section, we saw that the steps to complete array operations can vary based on the position of the data. We sometimes arrange and organize data in such a way that it is more readable and faster to find what we’re looking for, and computers can benefit from this too. A data structure that contains sorted data, such as a numerical sequence stored in an array, takes fewer steps to complete an operation such as reading or insertion. Sorting algorithms also take several steps to complete the sorting process. We will explore the selection sort algorithm, which is a common sorting algorithm that finds the smallest element in a data structure and moves it to the front. Let’s dive in by exploring an example of an array that contains four integers:
Figure 8.13 – An unsorted array of integers
We can easily organize this sequence in our heads, but writing an algorithm to do this will...