Skip to content

Fenwick Tree's select method gives incorrect answer #85

Open
@rchavesf

Description

@rchavesf

Sometimes the method won't return the correct value.

How to reproduce:

FenwickTree ft(10);
for (int i = 1; i <= 10; i++){
    ft.update(i,1);
}
for (int i = 1; i <= 10; i++){
    cout << ft.select(i) << "\n";
}

Expected output:

1
2
3
4
5
6
7
8
9
10

Obtained result:

1
2
3
4
5
6
7
8
16
16

Code execution: https://ideone.com/k5IMXN

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions