How to solve problems with Binary Indexed Tree?

335 Views Asked by At

This question sounds very vague and needs some explanation:

I learned about Binary Indexed Tree a few weeks ago. This data structure is a brilliant design. It actually took me very long to figure out how it's built thanks to this video (I mean... this is the first time I couldn't understand a written documentation and have to watch someone drawing a BIT step by step..)

Anyway, so (I think) I know how to build a BIT and the basic idea behind the structure design.. And now, I'm excited to practise some problems that can be easily solved with BIT.. In fact, someone has gathered a list of nice problems in this Quora post. I also tried some on HackerRank.

I spent long time trying and only managed to solve two (one by myself, the other taken from other's solution).. For instance, this direct connections problem..

I realise that the problem is never about how to build a BIT. The real challenge is to conceptualise the problem and use BIT to solve it... this is really beyond my imagination.. Is there a technique that I can use to tackle such problems?

And the interesting observation is.. for each problem set, the discussion below contains some comments like:

"BIT... :)"

It's like whoever managed to solve the problem always ended up with a proud smiley face without further explanation :(

Also, are there some classical problems that are solved by BIT?

EDIT

For those who voted to close this question: please give a valid reason. I believe this question is worth a discussion here!

0

There are 0 best solutions below