Treap Without A Key

You need an array supporting insert at a position, erase at a position, reverse a subrange, and range sum, with 10510^5 mixed operations. What do you build?

A

A skip list keyed by value: search by key rather than by rank, so a node's position follows from its key. All four are O(log⁡n)O(\log n) expected, with reversal as a lazy flag.

B

An implicit treap: split by subtree size rather than by value, so a node's position is its in-order rank. All four are O(log⁡n)O(\log n) expected, with reversal as a lazy flag.

C

A Fenwick tree over positions: index by prefix count rather than by value, so a node's position is a prefix sum. All four are O(log⁡n)O(\log n) worst case, with reversal handled by a second Fenwick.

D

A lazy segment tree over positions: address by leaf slot rather than by value, so a node's position is its leaf index. All four are O(log⁡n)O(\log n) worst case, with insertion into the next free leaf.