ankit_gupta_'s blog

By ankit_gupta_, history, 6 years ago, In English

Please help me with some doubts, I was reading 2D BIT, gfg implementation https://www.geeksforgeeks.org/two-dimensional-binary-indexed-tree-or-fenwick-tree/

In the updateBit and getSum function inner loop, "y" is not initialized again, can someone explain me how is it working and what is the need of outer loop as the same work can be done with the help of an "if" statement.

Thanks in advance..

  • Vote: I like it
  • -8
  • Vote: I do not like it

»
6 years ago, # |
  Vote: I like it +3 Vote: I do not like it

That's just wrong, you should initialize y on each step with the value of the query. You better check the link to topcoder in a reference section of this article.