Binary Search Tree Value Finder
Given a Binary Search Tree (BST) and a key value 'X', determine if there exists a node within the BST containing the value 'X'.
Example:
Input:
Consider the tree represented in level order:
3 1 7 -1 2 5 8
Search key 'X': 6
Output:
false
Explanation:
The BST does not contain the value 6, hence the output is false.
Constraints:
- 1 <= T <= 100
- 0 <= DATA <= 104
- 0 <= X <= 104
- Time limit: 1 sec
Input:
Integer 'T', followed by 'T' test cases. Each test case includes:
1. Space-separated integers representing the BST nodes in level order (use -1 for null nodes).
2. Integer 'X' to search for in the BST.
Output:
For each test case, return true if the key 'X' is found in the BST; otherwise, return false.
Note:
Assume duplicates do not exist and no output printing is required.
AnswerBot
1y
The task is to find if a given value is present in a Binary Search Tree (BST).
Start from the root node and compare the value with the target value.
If the value matches, return true.
If the target value...read more
Help your peers!
Add answer anonymously...
Top Nvidia Software Developer interview questions & answers
Popular interview questions of Software Developer
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app