Binary tree buildtree function using true false

I am not able to take user input to build a binary tree using the format used in questions at hacker blocks.(the true , false input) , I have built tree using the conventional (d==-1) method.

@priyam04 hey priyam tiwari , see this function

please tell how would you process the below input string using your function.

10 true 20 true 40 false false true 50 false false