Tree Find
Execution time limit is 1 second
Runtime memory usage limit is 128 megabytes
Binary search tree is given. Find element in a tree.
Definition of a tree:
// Java class TreeNode { public: int val; TreeNode left; TreeNode right; TreeNode(int x) { val = x; left = NULL; right = NULL; };
// C++ class TreeNode { public: int val; TreeNode *left; TreeNode *right; TreeNode(int x) : val(x), left(NULL), right(NULL) {} };
Implement function Find that returns pointer to the element found. If element does not exist, return NULL.
// Java TreeNode Find(TreeNode tree, int element)
// C++ TreeNode* Find(TreeNode *tree, int element)
Example
Function Find with element = 9 returns pointer to the node with value 9.
Submissions 2K
Acceptance rate 55%