Total Pageviews

Monday, August 31, 2026

🔷 SELECTION SORT VISUALIZER

```
🔷 SELECTION SORT VISUALIZER
Interactive Step-by-Step Sorting • Comparisons • Minimum Selection • Swapping
```
```

📥 Enter Your Values

⚡ Animation Speed
```
```

📊 Live Sorting Animation

🔵 CURRENT
🟡 MINIMUM
🟣 COMPARING
🟢 SORTED
```
```

📈 Live Statistics

Pass 0
Current -
Minimum -
Comparisons 0
Swaps 0
Ready to sort your array.
```
```

📝 Step-by-Step Explanation

1
Selection Sort repeatedly searches the unsorted portion of the array for the smallest element.
```
```

🧮 Selection Sort Mathematics

For every position i:

MIN = i
Compare A[j] with A[MIN]

If A[j] < A[MIN]:
MIN = j

Finally:
Swap A[i] and A[MIN]

``` for i = 0 to n - 2     MIN = i          for j = i + 1 to n - 1         if A[j] < A[MIN]             MIN = j          swap(A[i], A[MIN]) ```
```
```

💡 How Selection Sort Works

1
Start from the first position. Assume the first unsorted element is the minimum.
2
Compare the current minimum with every remaining unsorted element.
3
If a smaller element is found, update the MIN position.
4
After the complete pass, swap the minimum element with the first unsorted element.
5
The first position is now sorted. Repeat the process for the remaining array.
```
```

⏱️ Complexity Analysis

Best Case O(n²)
Average Case O(n²)
Worst Case O(n²)

Selection Sort performs almost the same number of comparisons regardless of whether the input is already sorted or unsorted.

```
```

🔢 Example of Comparisons

For n = 5 elements:

Comparisons = (n − 1) + (n − 2) + (n − 3) + ... + 1

= 4 + 3 + 2 + 1

= 10 comparisons
```

No comments:

Post a Comment