0% found this document useful (0 votes)
25 views1 page

Binary Search Tree Query Operations

The document outlines a task involving a binary search tree (BST) where a series of queries are executed to either insert a value or check for its existence and remove it. For each existence check, the output should be 1 if the value exists and 0 if it does not. The document also references additional resources related to graph traversal and a specific problem on LeetCode.

Uploaded by

kunalsvlogs2000
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views1 page

Binary Search Tree Query Operations

The document outlines a task involving a binary search tree (BST) where a series of queries are executed to either insert a value or check for its existence and remove it. For each existence check, the output should be 1 if the value exists and 0 if it does not. The document also references additional resources related to graph traversal and a specific problem on LeetCode.

Uploaded by

kunalsvlogs2000
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

BST queries

You are given Q queries in the form of a 2D array queries of size Q x 2. You have to
implement a binary search tree and apply these Q queries to it. Let the query be of the form
[X, Y].

 If X = 0, insert Y in the binary search tree.

 If X = 1, tell if Y exists in the binary search tree or not, and if it does exist, remove it
from the tree.

Note: If in an insert query, Y already exists in the binary search tree, ignore that query.
Task
For each query where X = 1, print 1 if Y exists in the binary search tree and print 0 if Y does
not exist in the binary search tree.

[Link]

Paint House III - LeetCode

You might also like