public int[] createTree(int input[], Operation operation){
        int height = (int)Math.ceil(Math.log(input.length)/Math.log(2));
        int segmentTree[] = new int[(int)(Math.pow(2, height+1)-1)];
        constructTree(segmentTree,input,0,input.length-1,0, operation);
        return segmentTree;
    }
Date 08/21/2014
@author tusroy

Video link - https://youtu.be/ZBHKZF5w4YU

A segment tree is a tree data structure for storing intervals, or segments. It allows 
for faster querying (e.g sum or min) in these intervals.
Write a program to support these operations for sum
createSegmentTree(int arr[]) - create segment tree
query(int segment[], int startRange, int endRange) - query in this range

Similar segment trees can be created for min or max.

Time complexity to create segment tree is O(nlogn)
Space complexity to create segment tree is O(nlogn)
Time complexity to search in segment tree is O(logn)
References
http://www.geeksforgeeks.org/segment-tree-set-1-sum-of-given-range/
http://www.geeksforgeeks.org/segment-tree-set-1-range-minimum-query/
src/com/interview/tree/SegmentTree.java