What happens if we apply the below operations on an input sequence? i. construct a cartesian tree for input sequence ii. put the root element of above tree in a priority queue iii. if( priority queue is not empty) then iv. search and delete minimum value in priority queue v. add that to output vi. add cartesian tree children of above node to priority queue

What happens if we apply the below operations on an input sequence? i. construct a cartesian tree for input sequence ii. put the root element of above tree in a priority queue iii. if( priority queue is not empty) then iv. search and delete minimum value in priority queue v. add that to output vi. add cartesian tree children of above node to priority queue Correct Answer sorts the input sequence

The above given steps are for sorting a cartesian tree. cartesian sort is benificial in case of partially sorted set of elements. a cartesian sort can be considered as a selection or heap sort maintaing a priority queue.

Related Questions

The following lines talks about deleting a node in a binary tree.(the tree property must not be violated after deletion) i) from root search for the node to be deleted ii) iii) delete the node at what must be statement ii) and fill up statement iii)