# Cartesian trees are most suitable for?

Category: QuestionsCartesian trees are most suitable for?
Editor">Editor Staff asked 5 months ago

Cartesian trees are most suitable for?

(a) searching

(b) finding nth element

(c) minimum range query and lowest common ancestors

(d) self balancing a tree

I need to ask this question from Cartesian Tree in chapter Binary Trees of Data Structures & Algorithms I

The question was posed to me in quiz.

Editor">Editor Staff answered 5 months ago

Correct option is (c) minimum range query and lowest common ancestors

Easiest explanation – In a cartesian tree minimum value can be found by finding lowest common ancestor for the extreme elements. consider 11,9,19,16 the lowest element is 9 and is a lowest common ancestor for 11 and 16. and by applying few techniques cartesian tree can be used to even find lowest common ancestors efficiently.

these can be done in constant time. tree can be constructed in linear time (this is the most efficient time for any tree construction) and takes space as many elements are there.

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