Function to construct segment tree from given array . This function allocates memory for segment tree and calls constructSTUtil ( ) to fill the allocated memory
int * constructSegmentTree ( int arr [ ] , int n ) { int height = ( int ) ( ceil ( log2 ( n ) ) ) ; int size = 2 * ( int ) pow ( 2 , height ) - 1 ; st = new int [ size ] ; constructST ( arr , 0 , n - 1 , 0 ) ; return st ; }