Cartesian trees solve range minimum query problem in constant time.

Category: QuestionsCartesian trees solve range minimum query problem in constant time.
Editor">Editor Staff asked 5 months ago

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
Editor">Editor Staff answered 5 months ago

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.


Notice: Trying to get property 'ID' of non-object in /home/fvckxqmi/public_html/wp-content/themes/blocksy/inc/single/single-helpers.php on line 17

Notice: Trying to get property 'ID' of non-object in /home/fvckxqmi/public_html/wp-content/themes/blocksy/inc/single/single-helpers.php on line 17

Notice: Trying to get property 'ID' of non-object in /home/fvckxqmi/public_html/wp-content/themes/blocksy/inc/single/single-helpers.php on line 17

Notice: Trying to get property 'ID' of non-object in /home/fvckxqmi/public_html/wp-content/themes/blocksy/inc/single/single-helpers.php on line 17
Articles: 40702