Segmentation fault error while checking whether it is a binary tree or not

I understand that this could be out of this forum but let me clarify why I have decided to post it here.

I try to submit a code problem but the grader doesn’t accept my result. I can’t see the test case, I see only the error message that states unknown signal 11 (Time used: 0.81/10.00, memory used: 101203968/536870912.)

I know that in signal #11 in Linux stands for segmentation fault. But I can’t get what’s wrong with my code. Other test cases are run without any problems. So I think that it is mostly design problem.

#!/usr/bin/python3  import sys, threading  sys.setrecursionlimit(10**7) # max depth of recursion threading.stack_size(2**25)  # new thread will get stack of such size  def IsBinarySearchTree(tree):   # Implement correct algorithm here   min = -sys.maxsize   max = sys.maxsize    def is_bst_until(idx_node,maxi,mini):     if idx_node == -1:       return True      node = tree[idx_node]     key = node[0]     idx_left = node[1]     idx_right = node[2]      #print('max',maxi, "min", mini)      if (key>maxi) or (key<mini):       #print("False", key, maxi,mini)       return False      return (is_bst_until(idx_right, maxi, key+1)) and (is_bst_until(idx_left, key-1, mini))    #print(tree)   if len(tree) == 0:       return True   return is_bst_until(0, max, min)   def main():   nodes = int(sys.stdin.readline().strip())   tree = []   for i in range(nodes):     tree.append(list(map(int, sys.stdin.readline().strip().split())))   if IsBinarySearchTree(tree):     print("CORRECT")   else:     print("INCORRECT")  threading.Thread(target=main).start() 

Input: The first line contains the number of vertices 𝑛. The vertices of the tree are numbered from 0 to π‘›βˆ’1. Vertex 0 is the root. The next 𝑛 lines contain information about vertices 0, 1, …, 𝑛 βˆ’ 1 in order. Each of these lines contains three integers π‘˜π‘’π‘¦π‘–, 𝑙𝑒𝑓𝑑𝑖 and π‘Ÿπ‘–π‘”h𝑑𝑖 β€” π‘˜π‘’π‘¦π‘– is the key of the 𝑖-th vertex, 𝑙𝑒𝑓𝑑𝑖 is the index of the left child of the 𝑖-th vertex, and π‘Ÿπ‘–π‘”h𝑑𝑖 is the index of the right child of the 𝑖-th vertex. If 𝑖 doesn’t have left or right child (or both), the corresponding 𝑙𝑒𝑓𝑑𝑖 or π‘Ÿπ‘–π‘”h𝑑𝑖 (or both) will be equal to βˆ’1.

Output: If the given binary tree is a correct binary search tree (see the definition in the problem description), output one word β€œCORRECT” (without quotes). Otherwise, output one word β€œINCOR- RECT” (without quotes).


3 1 1 2 2 -1 -1 3 -1 -1 INCORRECT  3 2 1 2 1 -1 -1 3 -1 -1 CORRECT