Анекдот про неспешный python. Возможно, вы знаете про...

Анекдот про неспешный python.

Возможно, вы знаете про такую структура данных Rope. Можно строку резать на подстроки, потом склеивать их в другом порядке, каждая операция за O(logn). Rope можно делать через Splay, Treap, Skip-List...

А можно резать и склеивать за O(n). В лоб.

Так вот, на python решение, делающее n операций, за O(n) каждую, работает быстрее, чем умное, делающее с помощью Treap за O(logn). При n = 100 000. В четыре раза быстрее.
Anecdote about slow python.

Perhaps you know about this data structure Rope. You can cut a string into substrings, then glue them in a different order, each operation in O (logn). Rope can be done through Splay, Treap, Skip-List ...

And you can cut and glue for O (n). Head-on.

So, in python, the solution that does n operations, with O (n) each, is faster than the smart one that makes with Treap using O (logn). When n = 100 000. Four times faster.
У записи 20 лайков,
0 репостов.
Эту запись оставил(а) на своей стене Sergey Kopeliovich

Понравилось следующим людям