Discuss Scratch
- Discussion Forums
- » Things I'm Making and Creating
- » Difference between Insert sort and Gnome sort
- Alberknyis
-
Scratcher
1000+ posts
Difference between Insert sort and Gnome sort
I've looked at different articles explaining gnome sort and insertion sort but I still have no idea how they're different.
Both of them check the previous item, and if the previous item is larger than the current item it moves the current item down until it is in its correct position.
Also, second question. I've thought of a sort like insertion sort, but instead of moving the element downward when its previous element is larger then it, it does a binary search to find which position it goes in. Is there a name for this sort?
Both of them check the previous item, and if the previous item is larger than the current item it moves the current item down until it is in its correct position.
Also, second question. I've thought of a sort like insertion sort, but instead of moving the element downward when its previous element is larger then it, it does a binary search to find which position it goes in. Is there a name for this sort?
- 24691357
-
Scratcher
100+ posts
Difference between Insert sort and Gnome sort
Gnome Sort behaves like insertion sort only when it's moving an element into its proper index. Unlike insertion sort, however, gnome sort makes comparisons even after placing an element in its proper spot. If it encounters a value that is out of place, it behaves like insertion sort again. The name of sort which does binary search is Binary Insertion Sort.
- Alberknyis
-
Scratcher
1000+ posts
Difference between Insert sort and Gnome sort
Gnome Sort behaves like insertion sort only when it's moving an element into its proper index. Unlike insertion sort, however, gnome sort makes comparisons even after placing an element in its proper spot. If it encounters a value that is out of place, it behaves like insertion sort again. The name of sort which does binary search is Binary Insertion Sort.Ah, thanks so much!
- fishu4
-
Scratcher
100+ posts
Difference between Insert sort and Gnome sort
what i think is the difference is that gnome sort actually swaps the item, and comparisons so its slower and insert sort only does comparasons, comparing it with the item it's going to insert and then moving it to the correct spot. tell me if i am wrong
- Discussion Forums
- » Things I'm Making and Creating
-
» Difference between Insert sort and Gnome sort