-
Notifications
You must be signed in to change notification settings - Fork 9.8k
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
pkg/adt: refactor + add more test cases #10959
Conversation
@xiang90 @xkeyideal This is still in progress. Still validating @xkeyideal's fix. Current branch includes a test case to prove that the current implementation is wrong, as described in #10877. |
Make "IntervalTree" an interface to abstract range tree interface Signed-off-by: Gyuho Lee <[email protected]>
@gyuho I saw your code, it seem delete function doesn't be modified, nil node should be coloring black, then delete node 11, the nil node can be coloring double black |
@xkeyideal Yes I am still working on this. I created this PR just to validate your test case. |
Signed-off-by: Gyuho Lee <[email protected]>
Signed-off-by: Gyuho Lee <[email protected]>
Signed-off-by: Gyuho Lee <[email protected]>
Described in etcd-io#10877. "black-height" property: Every path from a node to any descendant leaf node must have the same number of black nodes. Expected After deleting 11 (requires rebalancing): [510,511] / \ ---------- -------------------------- / \ [383,384] [830,831] / \ / \ / \ / \ [261,262](red) [410,411] [647,648] [899,900](red) / \ \ / \ / \ \ / \ [82,83] [292,293] [815,816](red) [888,889] [972,973] \ / \ / [238,239](red) [953,954](red) Got After deleting 11 (requires rebalancing): [510,511] / \ ---------- -------------------------- / \ [82,83] [830,831] \ / \ \ / \ [383,384] [647,648] [899,900] / \ \ / \ / \ \ / \ [261,262] [410,411] [815,816] [888,889] [972,973] / \ / / \ / [238,239] [292,293] [953,954] This violates "black-height" property. Signed-off-by: Gyuho Lee <[email protected]>
Is the bug about correctness or just performance? |
Signed-off-by: Gyuho Lee <[email protected]>
Signed-off-by: Gyuho Lee <[email protected]>
Can you help merge this? This doesn't change any behavior with current implementation. I created a separate issue to track this. I think we need more time to work on this, in 3.5. |
Codecov Report
@@ Coverage Diff @@
## master #10959 +/- ##
==========================================
- Coverage 64.21% 63.88% -0.33%
==========================================
Files 401 401
Lines 37473 37521 +48
==========================================
- Hits 24062 23970 -92
- Misses 11804 11936 +132
- Partials 1607 1615 +8
Continue to review full report at Codecov.
|
LGTM. Thanks! Let's work on this in v3.5. |
Introduction to Algorithms by Charles E. Leiserson, Clifford Stein, Ronald Rivest, and Thomas H. Cormen:
Current delete operation violates "black-height" property.
For example, given this red-black tree:
Let's delete the node
11
.The tree should be rebalanced as below:
However, current implementation returns:
This violates "black-height" property.
Fix #10877.