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

Switch to a simpler algorithm for placing hte interval tree array elements. #73868

Merged
merged 10 commits into from
Jun 6, 2024

Conversation

CyrusNajmabadi
Copy link
Member

No description provided.

@CyrusNajmabadi CyrusNajmabadi requested a review from a team as a code owner June 6, 2024 02:12
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels Jun 6, 2024
@@ -416,4 +416,31 @@ public void TestProperBalancing()
AssertEx.Equal(tree, Enumerable.Range(1, i));
}
}

[Fact]
public void TestVeryLargeBalancing()
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i wnated tests that also validated the edge cases in large trees to ensure the math was scaling up properly.

{
for (var i = 10; i < 20; i++)
{
var totalCount = 1 << i;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

trees up to 1m elements in size.

BuildCompleteTreeRecursive(source, destination, midPoint + 1, endExclusive, GetRightChildIndex(destinationIndex));
// The total tree height. If we're perfect, it's the height of the perfect portion. Otherwise
// it's one higher (to fit the remaining incomplete row).
var treeHeight = isPerfect ? perfectPortionHeight : perfectPortionHeight + 1;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isPerfect

would it make things a bit simpler later in the code to just return the value if perfect at this point?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will do in followup.


// Here we can figure out which case we have, and where the pivot it. First, we start with
//
// 1. `a = subtreeNodeCount - perfectSectionNodeCount`. The number of elements in the 'incomplete' last row.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a = subtreeNodeCount - perfectSectionNodeCount

nit: consider moving a couple of these expressions to their own variables

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will do in followup.

Copy link
Contributor

@ToddGrun ToddGrun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@CyrusNajmabadi CyrusNajmabadi merged commit 28e7bb2 into dotnet:main Jun 6, 2024
25 checks passed
@CyrusNajmabadi CyrusNajmabadi deleted the flatIntervalTree5 branch June 6, 2024 17:17
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone Jun 6, 2024
@jjonescz jjonescz removed this from the Next milestone Jun 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants