
Asked in Jupiter Money
Partial BST Problem Statement
Check if a given binary tree is a Partial Binary Search Tree (BST). A Partial BST adheres to the following properties:
- The left subtree of a node contains only nodes with data less than or equal to the node’s data.
- The right subtree of a node contains only nodes with data greater than or equal to the node’s data.
- Both left and right subtrees must also be Partial BSTs.
Input:
The first line contains an integer 't', the number of test cases. Each test case is described by the next lines:
The elements of the tree in level order form, space-separated. Use -1 to denote the absence of a child node.
Output:
For each test case, return 'true' if the binary tree is a Partial BST, 'false' otherwise. Each result will be on a separate line.
Example:
Input:
1
1 2 3 4 -1 5 6 -1 7 -1 -1 -1 -1 -1 -1
Output:
true
Constraints:
- 1 ≤ T ≤ 100
- 1 ≤ N ≤ 1000
- -109 ≤ data ≤ 109
Note:
You are not required to print anything; the implementation should simply return the result.

AnswerBot
4mo
Check if a binary tree is a Partial Binary Search Tree (BST) based on specific properties.
Traverse the tree in level order and check if each node satisfies the properties of a Partial BST.
Use recursio...read more
Help your peers!
Add answer anonymously...
Top Software Developer Intern Interview Questions Asked at Jupiter Money
Q. Merge Two Sorted Linked Lists Problem Statement You are provided with two sorted...read more
Q. Shortest Path in an Unweighted Graph The city of Ninjaland is represented as an ...read more
Q. Capture Region Problem Statement You are given a matrix having N rows and M colu...read more
Interview Questions Asked to Software Developer Intern at Other Companies
Top Skill-Based Questions for Jupiter Money Software Developer Intern
C++ Interview Questions and Answers
300 Questions
Algorithms Interview Questions and Answers
250 Questions
Data Structures Interview Questions and Answers
250 Questions
Web Development Interview Questions and Answers
250 Questions
Operating Systems Interview Questions and Answers
250 Questions
System Design Interview Questions and Answers
250 Questions
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

