Skip to main content

Vertical Sum of given Binary Tree

The vertical sum of a binary tree is the sum of node values that are on the same vertical line in the binary tree.

Vertical order sum of binary tree nodes

In a binary tree, each node has a horizontal distance from the root node, which is defined as the distance from the root node to the node measured in terms of the number of edges. The left child of a node has a horizontal distance that is one less than its parent, while the right child has a horizontal distance that is one more than its parent.

The vertical sum of a binary tree is the sum of all the node values that have the same horizontal distance from the root node.

Code Solution





Comment

Please share your knowledge to improve code and content standard. Also submit your doubts, and test case. We improve by your feedback. We will try to resolve your query as soon as possible.

New Comment