1.

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 orderThis interesting question is from Binary Trees topic in chapter Binary Trees of Data Structures & Algorithms IThe question was asked at a job interview.

Answer»

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.



Discussion

No Comment Found

Related InterviewSolutions