http://www.geeksforgeeks.org/segment-tree-set-1-range-minimum-query/ These posts describe lazy propagation, a very useful technique: http://isharemylearning.blogspot.gr/2012/08/lazy-propagation-in-segment-tree.html http://se7so.blogspot.gr/2012/12/segment-trees-and-lazy-propagation.html ...
Since a Segment Tree is a binary tree, a simple linear array can be used to represent the Segment Tree. https://leetcode.com/articles/a-recursive-approach-to-segment-trees-range-sum-queries-lazy-propagation/ https://www.hackerearth.com/zh/practice/data-structures/advanced-data-structures/segmen...
Building an O(n^2) segment tree is very expensive, your implementation took O(n^2) just to build the tree. Sparse table can be built in the same speed and compute rmq in O(1), as opposed to O(logn). The only advantage this 2D segment tree still has over the sparse table is O(...