JavaScript is required for this website. Please allow JavaScript and refresh the page.
home Home
sort Sorts
LOGARITHMIC
Quick Sort Merge Sort Heap Sort
QUADRATIC
Bubble Sort Selection Sort Insertion Sort Gnome Sort Shaker Sort Odd Even Sort Pancake Sort
WEIRD
Bitonic Sort Radix Sort Shell Sort Comb Sort Bogo Sort
CUSTOM
Your Sort
SORT VISUALIZER
Gnome Sort
Elements: 100
DESCRIPTION

Gnome Sort is a sorting algorithm really similar to Insertion sort. Gnome Sort is based on dividing the data structure in two sublists: a sorted one, and an unsorted one. For every cycle, the algorithm picks an element of the unsorted sublist and moves it with sequential swaps to the right position in the sorted sublist.

The main difference from the Insertion Sort is that the implementation doesn't require nested loops. Like the Insertion Sort, this algorithm is more efficient on small data structures almost sorted.

COMPLEXITY
Average Complexity O(n2)
Best Case O(n)
Worst Case O(n2)
Space Complexity O(1)