Watch Your Gnome Go With Gnome Sort!
Vložit
- čas přidán 9. 07. 2024
- Everyone loves gnomes :) In this Algorithm Monday video, we look at Gnome Sort, a sorting algorithm that correctly orders an array. It has a O(n^2) which is inefficient, but it is an excellent step to understanding sorting algorithms and programming architecture better! Hit subscribe and get in on all the sorting algorithms!
Sorting Algorithms: • Sorting Algorithms
Alg Monday: • Algorithm Monday
Big O Notation: • Something Every Self-t...
0:00 - How Gnome Sort Works
1:35 - Board Example
3:39 - Psuedocode
4:21 - Code In Python
7:00 - Compare to Insertion, Bubble, Selection - Věda a technologie
At first glance, I thought why not start from i=1 since the first part of the IF statement will always fulfill the first index and increment i, but then I noticed that when the first 2 numbers are not in the correct order i will decrement to 0 and then will go out of range for arr[i - 1]
My brain needed this kick and it starts spinning again (at least for now)
Thanks Rob!
Simple sorting algorithms are an amazing thing! Thanks for sharing!