Worse is better. Is there an example?

前端 未结 24 913
予麋鹿
予麋鹿 2020-12-12 19:03

Is there a widely-used algorithm that has time complexity worse than that of another known algorithm but it is a better choice in all practical si

24条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-12 19:56

    1. Y-fast-trie has loglogu time complexily for successor / predecessor but it has relativly big constants so BST (which is logn) is probably better, this is because log(n) is very small anyways in any practical use so the constants matter the most.

    2. Fusion tree have an O(logn/loglogu) query complexity but with very big constants and a BST can achieve the same in logn which is better again (also loglogu is extremely small so O(logn/loglogu)=O(logn) for any practical reason).

    3. The deterministic median algorithm is very slow even though it's O(n), so using a sort (nlogn) or the probabilistic version (theoretically could take O(n!) but with a very high probability it takes O(n) and the probability it would take T*O(n) drops exponentially with T) is much better.

提交回复
热议问题