1.

Cartesian trees solve range minimum query problem in constant time.(a) true(b) falseThe above asked question is from Cartesian Tree topic in section Binary Trees of Data Structures & Algorithms IThis question was addressed to me during an internship interview.

Answer»

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.



Discussion

No Comment Found

Related InterviewSolutions