What is the condition for priority of a node in a treap?

Category: QuestionsWhat is the condition for priority of a node in a treap?
Editor">Editor Staff asked 5 months ago

What is the condition for priority of a node in a treap?
 
(a) a node’s priority should be greater than its parent
 
(b) a node’s priority should be at least as large as its parent
 
(c) the priority is randomly assigned and can have any value
 
(d) a node’s priority is always given in decreasing order
 
This interesting question is from Binary Trees topic in chapter Binary Trees of Data Structures & Algorithms I
 
The question was asked at a job interview.

1 Answers
Editor">Editor Staff answered 5 months ago

Right choice is (b) a node’s priority should be at least as large as its parent
 
Best explanation: A node’s priority should satisfy heap order. That is, any node’s priority should be at least as large as its parent.


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