/** * Interface for tree nodes used in rebalancing */ export interface TreeNode { name: string; children: TreeNode[]; value: number; } /** * Helper function to rebalance a tree according to the following rules: * - Each node value must equal the sum of its immediate children with adjustments * - Can only add to nodes, no subtraction * - Excess value from parents is distributed evenly among all children * - Minimize the sum of all leaf nodes * * The function does not mutate the tree. Instead, it returns an adjustments map * indicating how much to add to each node to achieve the balanced state. * * @example * Tree structure: * root(20) * / \ * a(4) b(6) * / \ / \ * c(5) d(1) e(2) f(3) * * After rebalancing, the adjusted values would be: * root(20) * / \ * a(10) b(10) * / \ / \ * c(7) d(3) e(4.5) f(5.5) * * The resulting adjustments map: * { * "root": 0, * "a": 6, * "b": 4, * "c": 2, * "d": 2, * "e": 2.5, * "f": 2.5 * } * * @param node The root of the tree to rebalance * @returns A map of node names to adjustment values */ export declare function rebalanceTree(node: TreeNode): Map; export default rebalanceTree; //# sourceMappingURL=TreeRebalanceUtil.d.ts.map