-
Notifications
You must be signed in to change notification settings - Fork 9
/
bst.ts
31 lines (18 loc) · 1.17 KB
/
bst.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import { BSTNode } from '../data-structures';
import { IBinaryTree, IBinaryTreeNode } from './binary-tree';
import { BinaryTreeDeletedResult, BinaryTreeNodeId, BinaryTreeNodePropertyName } from '../types';
export type IBSTNode<T, NEIGHBOR extends IBSTNode<T, NEIGHBOR>> = IBinaryTreeNode<T, NEIGHBOR>;
export interface IBST<N extends BSTNode<N['val'], N>> extends IBinaryTree<N> {
createNode(id: BinaryTreeNodeId, val?: N['val'], count?: number): N;
add(id: BinaryTreeNodeId, val?: N['val'] | null, count?: number): N | null | undefined;
get(nodeProperty: BinaryTreeNodeId | N, propertyName?: BinaryTreeNodePropertyName): N | null;
lastKey(): BinaryTreeNodeId;
remove(id: BinaryTreeNodeId, ignoreCount?: boolean): BinaryTreeDeletedResult<N>[];
getNodes(nodeProperty: BinaryTreeNodeId | N, propertyName?: BinaryTreeNodePropertyName, onlyOne?: boolean): N[];
// --- start additional functions
lesserSum(id: BinaryTreeNodeId, propertyName?: BinaryTreeNodePropertyName): number;
allGreaterNodesAdd(node: N, delta: number, propertyName?: BinaryTreeNodePropertyName): boolean;
perfectlyBalance(): boolean;
isAVLBalanced(): boolean;
// --- end additional functions
}