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

Incorrect updating in Segment Tree? #91

Open
bandgeekdante opened this issue Aug 14, 2021 · 1 comment
Open

Incorrect updating in Segment Tree? #91

bandgeekdante opened this issue Aug 14, 2021 · 1 comment

Comments

@bandgeekdante
Copy link

st[p] = (lsubtree <= rsubtree) ? st[l(p)] : st[r(p)];

I think that this line should just use conquer(lsubtree,rsubtree), as currently it doesn't use the lazy value if applicable, and only checks for the minimum rather than what the conquer function specifies

@bandgeekdante
Copy link
Author

Actually I think you can replace lines 62-64 with simply conquer(l(p), r(p)) since the code has already called update on both l(p) and r(p), and update always begins with propagate which ensures that the two children won't have lazy flags set.

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

No branches or pull requests

1 participant