Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm. I think greater is correct, unless I'm confused?
[2, 5)is not a valid subtree because it makes this tree:But then
[0, 5)looks like this, which doesn't contain that tree:So if the subtree has size 3, we need start to be 4-aligned, not just 2-aligned.
But in that case "largest power of 2" should be "smallest power of 2".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yes, you're right--thanks for the catch and the counterexample! I agree the correct version is "If
kis the smallest power of 2 that is greater than or equal toend - start,startmust be a multiple ofk", since for any size subtree we want the start index to be aligned with the next-greatest power of two.I got confused since RFC9162 and the subtree consistency proof section say "let k be the largest power of two smaller than n", but we're dealing with a different
khere--thatkis for a split index, but thekhere is a restriction on the subtree start index. Maybe we pick a new letter likesfor "start"?