Sorting Algorithm Visualizer

Selection Sort (Brute Force)

Selection Sort is a simple brute-force sorting algorithm that repeatedly finds the minimum element from the unsorted part of the array and puts it at the beginning. The algorithm divides the input array into two parts: the sorted subarray and the unsorted subarray.

Time Complexity: O(n²) for both best and worst cases, making it inefficient for large arrays.

Limitations: Selection sort always performs O(n²) comparisons making it inefficient for large datasets. It does not adapt to the data being sorted (i.e., its runtime is the same regardless of the input). Its main advantage is simplicity and minimal memory usage.

Current Position
Comparing
Sorted
Step 1 of 0

Merge Sort (Divide and Conquer, Recursive)

Merge Sort is an efficient, divide-and-conquer algorithm that divides the input array into two halves, recursively sorts them, and then merges the sorted halves. Its recursive approach creates a tree of subproblems, solving them from the bottom up.

Time Complexity: O(n log n) for all cases (best, average, worst).

Limitations: While more efficient than selection sort, merge sort requires additional O(n) space for the merging process, making it less memory-efficient than in-place sorting algorithms. It's excellent for large datasets but might be overkill for very small arrays where simpler algorithms can perform better due to lower constant factors.

Current Position
Comparing
Sorted
Left Subarray
Right Subarray
Step 1 of 0