Gnome Sort Visualization


Gnome Sort - Sorting Algorithm Visualizer

DESCRIPTION

Gnome Sort is a **comparison-based sorting algorithm** that works by repeatedly swapping adjacent elements that are out of order, similar to how a gnome sorts flower pots by moving them one at a time until they are in order.

The algorithm starts at the beginning of the array and compares adjacent elements. If they are in order, it moves forward; otherwise, it swaps them and steps backward. This process continues until the entire array is sorted.

Gnome Sort has a **worst-case and average time complexity of O(n²)**, making it inefficient for large datasets. However, for nearly sorted data, it can perform close to **O(n)**, similar to Insertion Sort.

One advantage of Gnome Sort is its **simplicity and ease of implementation**, requiring no extra memory, making it an **in-place sorting algorithm**. It is also a **stable sort**, meaning equal elements retain their original order after sorting.

Despite its inefficiency on large datasets, Gnome Sort is useful for educational purposes and small datasets where simplicity is preferred over performance.

COMPLEXITY

Average Complexity O(n²)
Best Case O(n)
Worst Case O(n²)
Space Complexity O(1)
Insertion Sort Visualization

Gnome SORT IMPLEMENTATION

                    
                
Gnome Sort Visualization