Wavelet Tree Cost

A wavelet tree over an array with alphabet size σ\sigma. What does it answer and at what cost?

A

The mode in a range, and how many values below xx in a range, in O(n)O(\sqrt{n}) per query. Build is O(nn)O(n \sqrt{n}) time and space. The array is static.

B

kk-th smallest in a range, and how many values below xx in a range, in O(log⁡σ)O(\log \sigma) per query. Build is O(nlog⁡σ)O(n \log \sigma) time and space. The array is static.

C

Range sum, and the maximum in a range, in O(1)O(1) per query. Build is O(nlog⁡n)O(n \log n) time and space, and the array accepts point updates in O(log⁡n)O(\log n).

D

kk-th smallest in a range, and how many values below xx in a range, in O(log⁡2n)O(\log^2 n) per query. Build is O(nlog⁡n)O(n \log n) time and space. The array accepts point updates.