cartesian-tree

Range Minimum Query <O(n), O(1)> approach (from tree to restricted RMQ)

醉酒当歌 提交于 2019-12-18 11:39:32
问题 So, I read this TopCoder tutorial on RMQ (Range Minimum Query), and I got a big question. On the section where he introduced the approach, what I can understand until now is this: (The whole approach actually uses methodology introduced in Sparse Table (ST) Algorithm, Reduction from LCA to RMQ, and from RMQ to LCA) Given an array A[N], we need to transform it to a Cartesian Tree, thus making a RMQ problem a LCA (Lowest Common Ancestor) problem. Later, we can get a simplified version of the