Build BST, getting infinite loop

https://ide.codingblocks.com/s/237845, please debug and tell me the mistake

@rohit267, your code is not correct , instead of taking n inputs you are taking 2^n inputs as you call for buildTree(n-1); two times, also you have to maintain property of bst that the left child is smaller than root and right child is greater than root

refer this code for more clarity:-

your code is giving wrong output, please check once before providing any code.

@rohit267 your code is correct , just pass arguments correctly
l to mid-1 and mid+1 to r

thank you very much vatsal