331. Search a Binary Search Tree
The tree is a binary search tree. Print Yes if the value x appears in it
and No otherwise.
The whole point of a search tree is that you never look at both children. Compare
x with the node: equal means found, smaller means it can only be on the left,
larger means it can only be on the right. Every step throws away half the tree.
That is binary search on a structure rather than an array, and on a balanced tree
it visits about log n nodes rather than n.
Constraints - `1 ≤ n ≤ 100000` - `-1000000000 ≤ value, x ≤ 1000000000` - All values are distinct and the tree is a valid search tree.
Input
The first line contains two integers n and x.
The second line contains n values, where node i holds the ith value.
Each of the next n lines contains the left and right child of node i,
using 0 for no child. Node 1 is the root, and the tree is a search tree.
Output
Print Yes or No on one line.
Hints
Four rungs, in order. The last two open once you have submitted an attempt. A wrong one counts.