Maximum node in a Binary Search Tree
Given an empty binary search tree with no nodes, you are asked to perform 3 kinds of queries:
insert x- insert the value
xin the BST
max- print the maximum value in the BST
qqueries, you are asked to write a program to perform these queries.
The first line of the input contains a single number
q(1 ≤ q ≤ 1000).
qlines contain queries. For all the
insertqueries the value of
xdoes not exceed in absolute value.
maxquery, the program should print the maximum value of the BST on a separate line.
7 insert 2 insert 1 max insert 0 max insert 4 print
2 2 0 1 4 2
Time limit: 1 seconds
Memory limit: 512 MB
Output limit: 1 MB