Maximum of a General Tree (out)

Write a program that reads a non-empty tree of integer numbers and
writes its maximum value. Your program should define the function
maxim(t) that returns the maxim of the values stored in a non-empty tree
t. The parameter t of function maxim(t) should be an object of the class
Tree, implemented in file simple_tree.py in the public files section of
the problem statement.

For example, given the following specification of a tree in pre-ordre,
where the value stored at each node is followed by its arity

Input

    1 4
      3 2
          6 0
          -6 0
      12 0
      2 4
         3 0
         5 2
           10 0
           -13 0
         11 0
         7 0
      8 0

Your program should write

Output

    12

Hint

Implement the following function in file simple_tree.py

    def maxim(t):
       ...

and call that function from main after reading the tree.

Problem information

Author: Josefina Sierra Santibáñez

Generation: 2026-01-25T14:04:25.036Z

© Jutge.org, 2006–2026.
https://jutge.org
