Skip to content
CampusEduX

Search in BST

Easyjavapythonccppjavascript

Given a Binary Search Tree and a target value, determine whether the value is present.

The BST is given in level order: M tokens, each an integer or null; the first token is the root.

Input Format

The first line contains an integer M. The second line contains M space-separated tokens (integers or null). The third line contains the integer target.

Output Format

Print 1 if target is present, otherwise print 0.

Related Problems

  • Minimum and Maximum in BST
    Easy · java, python, c, cpp, javascript
    Solve Problem
  • Insert into BST
    Medium · java, python, c, cpp, javascript
    Solve Problem
  • Delete from BST
    Medium · java, python, c, cpp, javascript
    Solve Problem

Input (stdin)

Output

Run your code to see output here...