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 4 weeks 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 4 weeks 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.