3 ms·
Best-case runtime = 1. Worst-case = infinity.
by moron4hire 11y ago
Best-case runtime = 1. Worst-case = infinity.
- AndrewOMartin 11y agoI think the joke is that in all cases but the best-case, you won't be around to observe it, this becomes practical once you can create a universe for every permutation and destroy all but the universe which notifies you that it's the best-case. In all good text books this is left as an exercise for the reader.
- AnimalMuppet 11y agoIn a really good text book, this is left as an exercise that the reader won't do.
- danieldk 11y agoNo, checking whether a list is sorted is O(n) ;). Bogosort is O(n) in the best case and O(inf) in the worst case).
- lisivka 11y agoOptimize out the check, so it will be O(1) in some cases. ;)