2023-09-12 11:10:09 +08:00
|
|
|
import {AVLTreeNode} from '../data-structures';
|
2023-08-23 23:03:19 +08:00
|
|
|
import {IBST, IBSTNode} from './bst';
|
|
|
|
import {BinaryTreeDeletedResult, BinaryTreeNodeId} from '../types';
|
|
|
|
|
2023-09-20 11:39:24 +08:00
|
|
|
export type IAVLTreeNode<T, NEIGHBOR extends IAVLTreeNode<T, NEIGHBOR>> = IBSTNode<T, NEIGHBOR>
|
2023-08-23 23:03:19 +08:00
|
|
|
|
|
|
|
export interface IAVLTree<N extends AVLTreeNode<N['val'], N>> extends IBST<N> {
|
|
|
|
|
2023-09-12 11:15:20 +08:00
|
|
|
add(id: BinaryTreeNodeId, val?: N['val'] | null): N | null | undefined
|
2023-08-23 23:03:19 +08:00
|
|
|
|
2023-09-12 11:15:20 +08:00
|
|
|
remove(id: BinaryTreeNodeId, isUpdateAllLeftSum?: boolean): BinaryTreeDeletedResult<N>[]
|
2023-08-23 23:03:19 +08:00
|
|
|
|
2023-09-18 22:04:39 +08:00
|
|
|
// _balanceFactor(node: N): number
|
|
|
|
//
|
|
|
|
// _updateHeight(node: N): void
|
|
|
|
//
|
|
|
|
// _balancePath(node: N): void
|
|
|
|
//
|
|
|
|
// _balanceLL(A: N): void
|
|
|
|
//
|
|
|
|
// _balanceLR(A: N): void
|
|
|
|
//
|
|
|
|
// _balanceRR(A: N): void
|
|
|
|
//
|
|
|
|
// _balanceRL(A: N): void
|
2023-09-12 11:15:20 +08:00
|
|
|
}
|