Example #1
0
 public static TreapNode <T> Merge(TreapNode <T> left, TreapNode <T> right)
 {
     if (left == null || right == null)
     {
         return(left ?? right);
     }
     if (left.priority > right.priority)
     {
         return(left.RightLink(Merge(left.right, right)));
     }
     return(right.LeftLink(Merge(left, right.left)));
 }