1416 - BST Problem 1 (I)   

Description

In this problem, please implement a binary search tree (BST).
You have to implement the following methods:


(1) Insert x:
      Insert an integer x into the BST if x hasn’t in the BST yet.
(2) Size x:
      Find the node x in the BST and print the number of nodes in this subtree.
      If x isn't in the BST, print -1.

Input

 For each subproblem:

(1) 1416: N <= 200
(2) 1417: N <= 10000
(3) 1418
: N <= 60000

N is the number of nodes in the tree.

Output

Sample Input  Download

Sample Output  Download

Tags




Discuss