Intersection by Merge
public static Cons intersectionm (Cons x, Cons y) {
return mergeint(llmergesort(x), llmergesort(y));}
public static Cons mergeint (Cons x, Cons y) {
if ( x == null || y == null ) return null;
else if ( first(x).equals(first(y)) )
return cons(first(x),
mergeint(rest(x),rest(y)));
else if ( ((Comparable) first(x))
.compareTo(first(y)) < 0)
return mergeint(rest(x), y);
else return mergeint(x, rest(y));}
(defun intersection (x y)
(mergeint (llmergesort x) (llmergesort y)) )
(defun mergeint (x y)
(if (or (null x) (null y))
nil
(if (= (first x) (first y))
(cons (first x)
(mergeint (rest x) (rest y)))
(if (< (first x) (first y))
(mergeint (rest x) y)
(mergeint x (rest y)) ) ) ) )
What is O()? Stack depth? Conses?