3 ms·
> some code from Stackoverflow that iterates over your DOM in O(n!^n!) OK, I'm curious. What's a legitimate problem where the most naive solution is O(n!^n!)?
by CGamesPlay 9y ago
> some code from Stackoverflow that iterates over your DOM in O(n!^n!)
OK, I'm curious. What's a legitimate problem where the most naive solution is O(n!^n!)?
- owenversteeg 9y agoThat was a joke, honestly I doubt anything would be that slow. There are a few algorithms that are O(n!) though.
- zlynx 9y agoThere was one I helped suggest fixes for on StackOverflow a while back. The program searched DOM nodes, found its target, split the node, inserted the two new nodes, and continued searching in the new node it had just inserted. The result of this was truly horrific performance. If one node contained thousands of matches, the repeated node removal, copying, inserting, repeat, took more than 30 seconds. 30 seconds on a 4 GHz machine.