Input: A binary tree T in which each node x contains a field worth[x], which is a (positive, zero, or negative) monetary value expressed as a real number.
Define (monetary) heritage of a node x to be the total worth of ancestors of x minus the total worth of proper descendants of x.
Output: A node x in T with maximum heritage.
Note: other than the field worth and left/right child pointers, nodes of the given tree do not have any additional fields that you may use to store computed values. You are not allowed to alter the content of any node or create a “working copy” of the tree.allowed to alter the content of any node or create a “working copy” of the tree.
yes it is a simple input output questions
Binary Tree:
Binary tree contains at most 2 child nodes (atmost 2 child means 0,or 1,or 2 child node contains a binary tree)
2 TYPES OF BINARY TREE
1.COMPLETE BNARY TREE
2.FULL BINARY TREE
1.COMPLETE BINARY TREE:
in binary tree creates first fill the left side to right side
in binary tree taken above question example:X is root node in binary tree
X left side child nodes fill the first than go to X right side child node
2.FULL BINARY TREE:
complete binary tree subset of full binary tree
N nodes contains a binary tree N-1 edges
HEIGHT OF BINARY TREE CALCULATES FORMULA=2H+1-1
its working copy of create a binary tree and its simple input and output questions of binary tree
Get Answers For Free
Most questions answered within 1 hours.