JOIN
Get Time
forums   
Search | Watch Thread  |  My Post History  |  My Watches  |  User Settings
View: Flat (newest first)  | Threaded  | Tree
Previous Thread  |  Next Thread
question about updating | Reply
Hello

When querying , I understand why to subtract idx & -idx = 2^r (where r is the position of the last non-zero digit).
However , when updating , I cannot understand why to add idx & -idx .
Suppose we updated element x , then the first BIT value to update is BIT[x]. Why is is guaranteed that [x + (x & -x)] is the next index to update (i.e the next BIT value which will by affected by updating element x) ?
Thanks.
RSS