Associated Course(s):
Interview Preparation
Geeks Classes in Noida

Given a **Binary Search Tree (BST)**, you need to find if a particular node(data) is present in the BST or not. If present print** 1**, else print **0**.

**Input Format:**

The first line of the input contains an integer **'T'** denoting the number of test cases. Then **'T'** test cases follow. Each test case consists of three lines. Description of test cases is as follows:

The First line of each test case contains an integer **'N'** which denotes the no of nodes to be inserted in the BST.

The Second line of each test case contains **'N'** space separated values denoting the values of the BST.

In the third line is an integer **x** denoting the node to be searched for.

**Output Format:**

The output for each test case will be 1 if the node is present in the BST else 0.

**Your Task:**

This is a function problem. you don't have to read any input. Your task is to complete the function** search **which returns **true **if the node with **value x** is **present **in the **BST else returns false**.

**Constraints:**

1 <= T <= 100

1 <= N <= 100

**Example:
Input**

2

7

2 81 87 42 66 90 45

87

4

6 7 9 8

11

1

0

Author: Shubham Joshi 1

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

Change_UserHandle | 161 |

codifica_amante | 120 |

PankajChhabra1 | 114 |

DeepakDeedarSingla | 103 |

shivam2303 | 100 |

KapilChhipa | 547 |

sagarsagar | 490 |

Sajid_Ali | 461 |

ApoorvaPrabhat10 | 458 |

AKASH24497 | 444 |

blackshadows | 5254 |

Ibrahim Nash | 5184 |

akhayrutdinov | 5111 |

Quandray | 4385 |

mb1973 | 3866 |

Login to report an issue on this page.