We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 90289ce commit 40b9db7Copy full SHA for 40b9db7
Data Structures/Binary_Indexed_Tree.java
@@ -1,7 +1,7 @@
1
public class Binary_Indexed_Tree {
2
3
public static void main(String[] args) throws IOException {
4
- //testting BIT
+ //testting BIT
5
BIT bit = new BIT(12);
6
bit.update(4, 1);
7
bit.update(3, 1);
@@ -22,12 +22,12 @@ public BIT(int n){
22
binary_indexed_tree = new int[++n];
23
maxVal = n;
24
}
25
-
26
- public void update(int index, int val){
27
- while (index <= maxVal){
28
- tree[index] += val;
29
- index += (index & -index); //last bit removal
30
- }
+
+ public void update(int index, int val){
+ while (index <= maxVal){
+ tree[index] += val;
+ index += (index & -index); //last bit removal
+ }
31
32
33
//Returns the cumulative frequency of index index
0 commit comments