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...
Nvidia Software Developer interview questions & answers
A Software Developer was asked Q. Order of People Heights Problem Statement Consider 'N' individuals numbered from...read more
A Software Developer was asked Q. Binary Search Tree Value Finder Given a Binary Search Tree (BST) and a key value...read more
A Software Developer was asked Q. What are Little Endian and Big Endian in the context of computer architecture?
Popular interview questions of Software Developer
A Software Developer was asked Q1. Order of People Heights Problem Statement Consider 'N' individuals numbered from...read more
A Software Developer was asked Q2. Binary Search Tree Value Finder Given a Binary Search Tree (BST) and a key value...read more
A Software Developer was asked Q3. What are Little Endian and Big Endian in the context of computer architecture?
Stay ahead in your career. Get AmbitionBox app


Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+
Reviews
10L+
Interviews
4 Cr+
Salaries
1.5 Cr+
Users
Contribute to help millions
AmbitionBox Awards
Get AmbitionBox app

