Every node in a binary search tree holds the following properties:
Given the root node of a binary tree, determine whether it's a binary search tree.
The first line contains an integer T denoting the number of test cases.
For each test case, the input has 2 lines:
For each test case, the output contains a line with 1 or 0 based on whether the binary tree is a binary search tree or not respectively.
5
7
6 4 8 1 5 -1 12
3
6 -1 4
2
6 8
6
17 11 28 -1 -1 18
1
6
1
0
0
1
1
1 <= T <= 10
1 <= n <= 105
1 <= node value <= 109