+1 vote
in Data Structures & Algorithms I by (110k points)
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.

1 Answer

+1 vote
by (672k points)
selected by
 
Best answer
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.

Related questions

Welcome to TalkJarvis QnA, a question-answer community website for the people by the people. On TalkJarvis QnA you can ask your doubts, curiosity, questions and whatever going in your mind either related to studies or others. Experts and people from different fields will answer.

Categories

...