Cartesian trees solve range minimum query problem in constant time.
(a) true
(b) false
The above asked question is from Cartesian Tree topic in section Binary Trees of Data Structures & Algorithms I
This question was addressed to me during an internship interview.
1 Answers
The correct answer is (a) true
The explanation is: Range minmum query is finding the minimum element in a given subarray of an array. Constant time is achieved by storing the Cartesian trees for all the blocks in the array. Rmq’s are used in string matchings, computing lowest common ancestor and longest common prefix of a sring.