Given two arrays of integers: array of keys and array values associated with keys. Create a Binary Search Tree from these numbers. If the inserted key equals to the key in the current node, insert it to the right subtree.
Write a method IsSymmetric that checks whether the tree with associated values is a mirror of itself (i.e. symmetric around its center).
Write the code according to the next interface:
You can create (use) additional methods if needed.
The first line contains number n (1 ≤ n ≤ 100). The second line contains n integers - keys: key[1], key[2], ..., key[n]
. The third line contains n integers - the associated values val[1], val[2], ..., val[n]
. The value val[i]
is associated with key key[i]
.
Create the Binary Search Tree from input data. Print 1 if the tree with associated values is symmetric and 0 otherwise.