How would you like to learn today?
Visualize algorithms in real time, explore them step by step, or challenge yourself with a test.Choose a path to focus—or scroll down to preview all options.
Visualize the algorithm step-by-step with interactive animations in real time.
Read the full explanation, examples, and starter code at your own pace.
Drag and arrange the algorithm steps in the correct execution order.
🧠 Select Active to activate
Follow every state change, comparison, and transformation as the execution unfolds in real time.
📖 Select Passive to activate
Difficulty: Easy
Topics: Sorting Algorithms, Iterative Methods
Companies: Commonly asked in technical interviews.
Selection sort is a sorting algorithm that iteratively selects the smallest element from the unsorted portion of the array and swaps it with the element at the beginning of the unsorted portion.
min_index) of the unsorted portion of the array.min_index to the current iterator value, assuming it is the smallest within the unsorted portion.min_index, update min_index to this element's index.min_index is different from the current iterator in the outer loop, swap the elements at min_index and the current iterator.Selection sort works by gradually building up a sorted portion of the array from left to right, ensuring that after each iteration of the outer loop, the left portion of the array is sorted correctly.
Selection sort operates with a time complexity of 𝑂(𝑛²), making it less efficient for large datasets compared to more advanced sorting algorithms like quicksort or mergesort.
[64, 25, 12, 22, 11]
11) and swap it with the first element.[11, 25, 12, 22, 64]12) and swap it with the second element.[11, 12, 25, 22, 64]22) and swap it with the third element.[11, 12, 22, 25, 64][11, 12, 22, 25, 64]
Advantages:
Disadvantages:
Use selection sort for educational purposes or small datasets. For larger datasets, consider more efficient algorithms like quicksort or mergesort.
— Written by Saurabh Patil • B.Tech CSE • Software Developer🎯 Select Challenge to activate
Drag and arrange the algorithm steps in the correct execution order instead of spending time typing code letter by letter.
The algorithm is divided into three logical parts. Carefully rearrange each section in the correct order to form a complete and valid solution.
Understand Below AlgorithmGreen text means the instruction is placed in the correct position.
Red text means the instruction is in the wrong position.
Instructions with the same background color indicate particular blocks start and end.
A tick mark means the instruction is correct and locked.
🔒 Locked steps cannot be moved. Only unlocked steps are draggable.
🔊 Enable sound for swap feedback and completion effects.