Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fenwick Tree's select method gives incorrect answer #85

Open
rchavesf opened this issue Mar 21, 2021 · 1 comment · May be fixed by #86
Open

Fenwick Tree's select method gives incorrect answer #85

rchavesf opened this issue Mar 21, 2021 · 1 comment · May be fixed by #86

Comments

@rchavesf
Copy link

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

@stevenhalim
Copy link
Owner

eh wait, this looks legit (will KIV), I check again later

@rchavesf rchavesf linked a pull request Mar 22, 2021 that will close this issue
@rchavesf rchavesf changed the title Bug in Fenwick Tree's select method Fenwick Tree's select method gives incorrect answer Jun 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants