# Determine whether a binary tree is a binary search tree (BST)

Aced (formerly Exponent) publishes a public search API over its indexed pages; the guide is at https://www.aced.io/agents/agent-access.

Source: https://www.aced.io/questions/1158/determine-binary-tree-bst
Source observed: 2026-11-04T23:00:12.591Z
Last checked: 2026-11-04T23:00:12.591+00:00
Indexed: 2026-11-07T00:20:31.84+00:00

---

# Determine whether a binary tree is a binary search tree (BST)

**Difficulty:** Medium  
**Category:** [Data Structures & Algorithms](https://www.aced.io/questions?type=algorithms&filterBy=codeEditor&src=nav)  
**Question URL:** [Open this question](https://www.aced.io/questions/1158/determine-binary-tree-bst)

We ask you to determine whether a given binary tree is a valid binary search tree (BST). The examples use level-order notation, with `root` representing the tree. Return `true` when the tree is a valid BST and `false` otherwise.

## Examples

```text
root = [5, 2, 6]
output: true

root = [5, 2, 4, null, null, 3, 6]
output: false

root = []
output: true
```

The empty tree is treated as a valid BST in the examples.

## Question details

- Reported last asked: 2 years ago
- Saved by 31 users
- Community answers: none contributed yet
- Interview experiences associated with this question: 3 shared

The question is associated with these roles:

- [Software Engineer](https://www.aced.io/questions?role=swe)
- [Data Engineer](https://www.aced.io/questions?role=data-engineer)
- [Data Scientist](https://www.aced.io/questions?role=data-science)
- [Machine Learning Engineer](https://www.aced.io/questions?role=ml-engineer)

The question is associated with these companies:

- [Meta](https://www.aced.io/questions?company=meta-facebook)
- [TikTok](https://www.aced.io/questions?company=tiktok)
- [Adobe](https://www.aced.io/questions?company=adobe)
- [Oracle](https://www.aced.io/questions?company=oracle)
- [Temenos](https://www.aced.io/questions?company=temenos)
- [Google](https://www.aced.io/questions?company=google)

## Interview experiences

### [Temenos — Software Engineer, Senior / L5](https://www.aced.io/experiences/temenos-senior-software-engineer-interview-551857)

Shared 2 years ago. The contributor described multiple interview rounds covering Core Java, Spring Boot, microservices, system design, databases, and previous banking and enterprise-software experience. They highlighted discussions about real-world projects, architecture decisions, domain experience, and system-architecture trade-offs, and described the process as professional, structured, and relevant to the role.

### [Google — Software Engineer, Mid Level / L4](https://www.aced.io/experiences/google-software-engineer-interview-2739ac)

Shared 3 years ago. The contributor recommended reading Google's study guide and described the process as classic data-structures-and-algorithms interviewing.

### [Meta — Software Engineer, Mid Level / L4](https://www.aced.io/experiences/meta-facebook-software-engineer-interview-0c22d6)

Shared 3 years ago. The contributor described the process as extremely smooth, noted that team matching was difficult, and said that candidates did not necessarily need every answer to be completely correct; one round was unfinished.

## Related questions

- [Delete Node in a Binary Search Tree (BST)](https://www.aced.io/questions/5156/delete-node-binary-search-tree)
- [Check if a given binary tree is a complete binary tree](https://www.aced.io/questions/1154/check-complete-binary-tree)
- [Check if a given binary tree is height balanced](https://www.aced.io/questions/1157/check-height-balanced-binary-tree)

## Related courses

### [Machine Learning Engineer Interview Prep](https://www.aced.io/courses/ml-engineer)

![Machine Learning Engineer Interview Prep](https://images.ctfassets.net/x78yjrjc11pq/6UfkHxUyLQVfDHSfLNQtWa/1be1539a65b4f6f15201f5b573c0a578/ML_Engineer_Interview_Prep_Course.jpeg?w=800&h=800&fm=webp&q=75)

We cover mock interviews, frameworks, advice from senior candidates, ML system design, core concepts, coding, and behavioral interviews for roles at Meta, Google, Amazon, Apple, Microsoft, Nvidia, and other companies.

### [Data Science Interview Prep](https://www.aced.io/courses/data-science)

![Data Science Interview Prep](https://images.ctfassets.net/x78yjrjc11pq/3U4C5C0OkDR0UeGch4AmlE/7ad489430b676a088cb973307fe77884/Data_Science_Interview_Prep_Course.jpeg?w=800&h=800&fm=webp&q=75)

We cover statistics, experimentation, coding, SQL, machine learning, behavioral interviews, mock interviews, frameworks, and advice from senior candidates for data-science roles at Google, Amazon, Microsoft, Meta, Apple, and other companies.

## Running code

Use [Sign up to run code](https://www.aced.io/signup?src=lesson) to run code in the editor. The available interface includes an editor, share view, output, test results, and console.

## More from Aced

We provide interview preparation through courses, practice questions, interview experiences, coaching, resume review, salary negotiation, job referrals, and other resources. Browse [all questions](https://www.aced.io/questions), [courses](https://www.aced.io/courses?src=nav), [experiences](https://www.aced.io/experiences?src=nav), [practice](https://www.aced.io/practice?src=nav), or [pricing](https://www.aced.io/upgrade?src=nav).

---

[Read this page’s summary](https://www.aced.io/agents/api/public/v1/page-tldr?url=https%3A%2F%2Fwww.aced.io%2Fquestions%2F1158%2Fdetermine-binary-tree-bst&trace=t_679ff9ab98f3)

## Ask a follow-up about this page

Need a more specific answer? Ask the exact question you have. It returns a fresh, cited answer from Aced (formerly Exponent)’s knowledge base. No account or API key required.

Open this URL with your own question, URL-encoded. Include your question in q. All research inputs are optional; no account or setup.

`GET https://www.aced.io/agents/agent/faq?q={question}&trace=t_679ff9ab98f3`

[Tool guide and examples](https://www.aced.io/agents/agent-access) · [OpenAPI](https://www.aced.io/agents/api/public/v1/openapi.json) · [Page TLDR form](https://www.aced.io/agents/agent-tools/page-tldr?url=https%3A%2F%2Fwww.aced.io%2Fquestions%2F1158%2Fdetermine-binary-tree-bst). Opening a form does not execute a tool.