Segmentation fault for static declaration


#1

can anyone explain why usage of preorder index as static variable gives us segmentation fault??
solve the problem by passing preorder index as reference.


#2

because your code is being tested on a number of test cases and if you use preorder index as static it will be same for all the test cases which will give error.