Тэги:
#tom_scott #tomscott #the_basics #computer_science #big_o_notation #sorting #sort_algorithms #bubble_sort #quick_sort #bogosortКомментарии:
I'm right now trying to implement a search algorithm for my own website (because somehow Google etc. fail to find almost anything on that site, they only know four of the approximately fifty pages on my website) and realized that I probably should just make the index and then let an existing algorithm search through it…
ОтветитьI miss this stuff.
ОтветитьMy favorite sorting algorithm is Stalin Sort. If a number is out of order, it gets sent to the gulag. Some data does die, but that is a sacrifice I am willing to make.
ОтветитьBubble sort only goes to index size -1 once.
ОтветитьIsnt the worst case of insertion sort and bubble sort O(nlogn)?
ОтветитьSaw this in my teenage and indeed avoided his mistakes
ОтветитьTheoretically, for sorting algorithms, the theoretical worst big-O you can get, for an algorithm that actually functions correctly as a sorting algorithm, is, as you showed `O(n!)` which is the bogosor algorithm.
The best possible big-O for a sorting algorithm is `O(n)` which is the quantum bogosort algorithm:
1. Randomize the list.
2. Check if it is sorted.
3. If it isn't sorted, destroy the universe.
This makes it so only universes where the list is sorted continue to exist. If the many-worlds interpretation is untrue, however, the results would be... unfortunate.
Big-O ignores all constants. `O((n+1)!)` is the same as `O(n!)` .
Ответитьbro really did bogosort 💀
ОтветитьWhen I was a teenager i didnt know what code was.
ОтветитьYou might as well been speaking gobble-de-gook for the amount I understood - none !
Ответить❤❤❤love ur effort to explaim
ОтветитьBogosort is 50/50 it's either in the correct order or its not.
ОтветитьI am slightly annoyed that Merge Sort was never mentioned
ОтветитьI used to do bogosort with my rubik's cube.
ОтветитьMan, that story was… relateable.
Ответить"Why spend 5 minutes doing something when you could spend 5 hours failing to automate it"
Ответитьyou want O(n!) for the best performance
ОтветитьI'm happy to say that after like 1 uear of watching this video, I've fonally found a use for this as my IT school wanted us to learn algorithms in C++
Also, yes I implemented Bogosort, and yes it was approved by the teachers
Now code it will grow with one.
Ответить