e01.org

Gnome sort

Gnome sort (nicknamed stupid sort) is a variation of the insertion sort sorting algorithm that does not use nested loops. Gnome sort was known for a long time and used without naming it explicitly. It was then popularized by Iranian computer scientist Hamid Sarbazi-Azad (professor of Computer Science and Engineering at Sharif University of Technology) in 2000. The sort was first called stupid sort (not to be confused with bogosort), and then later described by Dick Grune and named gnome sort. Gnome sort performs at least as many comparisons as insertion sort and has the same asymptotic run time characteristics. Gnome sort works by building a sorted list one element at a time, getting each... Source: e01 Encyclopedia. Licence: CC BY-SA 4.0.

Gnome sort (nicknamed stupid sort) is a variation of the insertion sort sorting algorithm that does not use nested loops. Gnome sort was known for a long time and used without naming it explicitly. It was then popularized by Iranian computer scientist Hamid Sarbazi-Azad (professor of Computer Science and Engineering at Sharif University of Technology) in 2000. The sort was first called stupid sort (not to be confused with bogosort), and then later described by Dick Grune and named gnome sort. Gnome sort performs at least as many comparisons as insertion sort and has the same asymptotic run time characteristics. Gnome sort works by building a sorted list one element at a time, getting each item to the proper place in a series of swaps. The average running time is O(n 2 ) but tends towards O(n) if the list is initially almost sorted. Dick Grune described the sorting method with the following story: pos := 1 while pos = a[pos-1]): pos := pos + 1 else: swap a[pos] and a[pos-1] pos := pos - 1 ===Example=== Given an unsorted array, a = [5, 3, 2, 4], the gnome sort takes the following steps during the while loop. The current position is highlighted in bold and indicated as a value of the variable pos . ==Notes== ==References== ==External links== Gnome sort

source: e01 Encyclopedia · licence: CC BY-SA 4.0 · page · source revision

Cite this

"Gnome sort". 1788238192. e01 Encyclopedia. CC BY-SA 4.0. https://en.wikipedia.org/w/index.php?oldid=1372560248

JSON record · API collection · BibTeX · RIS · CSL-JSON · citation policy

Save to pass ·