....
> solution he/she used 2 functions :
>
> public void add(int pos) {
>                 while (pos < 20000) {
>                         s[pos]++;
>                         pos = (pos | (pos-1)) + 1;
>                 }
>         }
>
>         public int getSum(int pos) {
>                 int sum = 0;
>                 while (pos > 0) {
>                         sum += s[pos];
>                         pos &= pos - 1;
>                 }
>                 return sum;
>         }
> iam not able to understand these statements.
>

Refer to BIT (Binary Indexed Trees). It is a kind of dynamic data
structure used to store cumulative values of some data.
There is a nice explanation on this in Topcoder Tutorials. I hope it
will help.

Thanks.

Rajat.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"google-codejam" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/google-code?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to