Insertion Sort Algorithm
Algorithm Steps:
- Assume the first element is already sorted.
- Take the next element from the unsorted part and compare it with elements in the sorted part.
- If the current element is smaller, shift the sorted elements to the right to make space for the current element.
- Insert the current element into its correct position in the sorted portion of the array.
- Repeat the process for all elements in the array until the entire array is sorted.
Example:
For instance, to find the number 8 in the list [12, 25, 8, 10, 32], the algorithm will check each element one by one until it finds the number.