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

Missing rebalance function #3

Open
nusrathsyed opened this issue Feb 26, 2023 · 1 comment
Open

Missing rebalance function #3

nusrathsyed opened this issue Feb 26, 2023 · 1 comment

Comments

@nusrathsyed
Copy link

nusrathsyed commented Feb 26, 2023

Looks like you're not rebalancing the tree on CRUD operations!

@Tyriar
Copy link
Member

Tyriar commented Feb 28, 2023

Long time since I looked at this, but it's rebalancing on insert and delete, no?

// Update height and rebalance tree
root.height = Math.max(root.leftHeight, root.rightHeight) + 1;
const balanceState = this._getBalanceState(root);

ts-avl-tree/src/avlTree.ts

Lines 167 to 169 in 3a1614d

// Update height and rebalance tree
root.height = Math.max(root.leftHeight, root.rightHeight) + 1;
const balanceState = this._getBalanceState(root);

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

2 participants