6 karma · joined May 19, 2019 (7y ago) · 1 submissions
comment 7y ago · link · parent
Better approach, imo, would be an order statistic tree with O(logN) insert, remove and O(logN+M) slice operations [2]. This would be usually implemented as an implicit treap [3]. Furthermore, balanced binary search trees can be implemented efficiently in a functional language like Elixir that doesn't have mutable data structures. One such example is Erlang's gb_tree [4].
[1] https://cp-algorithms.com/data_structures/sqrt_decomposition...
[2] http://www.cs.yale.edu/homes/aspnes/pinewiki/OrderStatistics...
[3] https://cp-algorithms.com/data_structures/treap.html#toc-tgt...