|
| 1 | +<h1 align='center'>SELECTION - SORT - ALGORITHM - PROBLEMS</h1> |
1 | 2 |
|
| 3 | +Welcome to the **Selection Sort Algorithm Problems** repository! This repository is dedicated to solving and understanding problems based on the **Selection Sort algorithm**, a fundamental sorting algorithm widely used in computer science. |
| 4 | + |
| 5 | +### Repository Content |
| 6 | +<p> |
| 7 | +<img src="https://img.shields.io/badge/problems%20count-01-orange?logo=leetcode" alt="LeetCode"> |
| 8 | +<img src="https://img.shields.io/badge/problems%20count-00-darkgreen?logo=geeksforGeeks" alt="GeeksforGeeks"> |
| 9 | +<img src="https://img.shields.io/badge/total%20problems%20count-01-blue" alt="Problem Count"> |
| 10 | +</p> |
| 11 | + |
| 12 | +| No | Problem Name | Description | Leetcode | GFG | |
| 13 | +|---|-------|-------------------|---|---| |
| 14 | +| 01 | [Sort Colors](https://github.com/JawadSher/DSA-LeetCode-GFG-Problems-Repository/tree/main/07%20-%20Sorting%20Algorithms%20Problems/01%20-%20Selection%20Sort%20Algorithm%20Problems/01%20-%20Sort%20Colors) | Sort an array with 0s, 1s, and 2s without using the library sort function. The goal is to group all the 0s, 1s, and 2s together, maintaining their relative order. | [Link](https://leetcode.com/problems/sort-colors/) | Non | |
| 15 | + |
| 16 | +## About Selection Sort |
| 17 | + |
| 18 | +Selection Sort is an in-place, comparison-based sorting algorithm. It divides the input list into two parts: |
| 19 | +1. **The sorted portion** (initially empty). |
| 20 | +2. **The unsorted portion** (initially containing all elements). |
| 21 | + |
| 22 | +The algorithm repeatedly selects the smallest (or largest, for descending order) element from the unsorted portion and places it at the end of the sorted portion. |
| 23 | + |
| 24 | +### Algorithm Steps: |
| 25 | +1. Start with the first element as the current minimum. |
| 26 | +2. Traverse through the unsorted portion to find the smallest element. |
| 27 | +3. Swap the smallest element with the first element of the unsorted portion. |
| 28 | +4. Move the boundary of the sorted portion one element to the right. |
| 29 | +5. Repeat until the entire array is sorted. |
| 30 | + |
| 31 | +### Characteristics: |
| 32 | +- **Time Complexity:** |
| 33 | + - Best Case: \(O(n^2)\) |
| 34 | + - Average Case: \(O(n^2)\) |
| 35 | + - Worst Case: \(O(n^2)\) |
| 36 | +- **Space Complexity:** \(O(1)\) (in-place sorting) |
| 37 | +- **Stability:** Not stable by default. |
| 38 | + |
| 39 | +--- |
| 40 | +Happy Coding 😊 |
0 commit comments