Today I will talk about an elegant way of answering rank queries on sequences over larger alphabets – a structure called the Wavelet Tree. In my last post I introduced a data structure called RRR, which is used to quickly answer rank queries on binary sequences, and provide implicit compression. A Wavelet Tree organises a string into a hierarchy of bit vectors. A rank query has time complexity is
![Wavelet Trees: an Introduction](https://cdn-ak-scissors.b.st-hatena.com/image/square/f5386bfff366e1b695e5a16efff9664aac1567b6/height=288;version=1;width=512/https%3A%2F%2Fs3-placid.s3.eu-central-1.amazonaws.com%2Fproduction%2Frest-images%2Fogmggaxdl%2Fghost-00d461ce261157da1fa033d2c8d18f78-xbap15bp.jpg)