# What Is Sequential Sort in Data Structure?

//

Heather Bennett

The sequential sort is a simple sorting algorithm that operates by repeatedly finding the minimum or maximum element from the unsorted part of the array and putting it at the beginning. This process is then repeated for the remaining elements until the entire array is sorted. Also known as selection sort, this algorithm is straightforward to understand and implement.

## The Sequential Sort Algorithm

The sequential sort algorithm can be broken down into the following steps:

1. Set a marker for the first unsorted element in the array.
2. Assume that this element is currently the minimum (or maximum) value.
3. Compare this element with the other elements in the array, starting from the second unsorted element.
4. If an element is found that is smaller (or larger) than the assumed minimum (or maximum), update the marker to this new element.
5. After iterating through all remaining elements, swap the found minimum (or maximum) element with the first unsorted element.
6. Move the marker to indicate that one fewer element is unsorted. Repeat steps 2-6 until all elements are sorted.

### An Example

Let’s illustrate how sequential sort works with an example:

Input Array: [7, 3, 9, 2]

• Step 1: The marker points to index 0 (value: 7).
• Step 2: Assume that index 0 holds the minimum value (7).
• Step 3: Compare index 0 with index 1 (value: 3). 3 is smaller, so update the marker to index 1.
• Step 4: Compare index 1 with index 2 (value: 9).

No update needed.

• Step 5: Compare index 1 with index 3 (value: 2). 2 is smaller, so update the marker to index 3.
• Step 6: Swap the minimum value (2) with the first unsorted element at index 0.

Array after one iteration: [2, 3, 9, 7]

The marker now points to index 1 (value: 3). Repeat steps from Step 2.

Array after two iterations: [2, 3, 9, 7]

The marker now points to index 2 (value:9). Repeat steps from Step.

Array after three iterations: [2,3,7,9]

### Time Complexity Analysis

The sequential sort algorithm has a time complexity of O(n^2), where n is the number of elements in the array. This is because for each element in the array, we need to compare it with all remaining elements. As a result, as the size of the array increases, the number of comparisons and swaps also increases quadratically.

### In Conclusion

The sequential sort algorithm is a simple yet inefficient sorting algorithm. Although it may not be suitable for large datasets due to its time complexity, it can still be useful for small arrays or when simplicity outweighs efficiency.

By repeatedly finding the minimum (or maximum) element and placing it at the beginning, the array gradually becomes sorted. With its clear steps and intuitive nature, the sequential sort algorithm serves as a fundamental sorting technique in data structures and algorithms.