Reconstruct binary tree from traversal data - variant 2

#1

[EPIJ v 1.6.1 problem 10.12 variant 2]

The problem says to compute the max-tree of an array. It specifies that for array A, the left child of the max-tree of A is a max-tree on the elements to the left (in A) of the root of A’s max-tree, and the right child is a max-tree on the elements to the right (in A) of the root of A’s max-tree. This establishes that the root and its left and right nodes are max-trees.

Is this property maintained for all nodes, i.e. all levels, in the tree? Or is it just the three nodes mentioned that are max-trees?

0 Likes

#2

It is all nodes. Must binary tree like definition is always recursive defined.

0 Likes