Contents    Page-10    Prev    Next    Page+10    Index   

Divide and Conquer Design Pattern

(defun myfun (problem)
         (if (basecase? problem)
                 (baseanswer problem)
                 (combine (myfun (firsthalf problem))
                  (myfun (secondhalf problem))) ))


(defun llmergesort (lst)
  (let (mid half)
    (if (or (null lst) (null (rest lst)))
        lst
        (progn (setq mid (midpoint lst))
               (setq half (rest mid))
               (setf (rest mid) nil)
               (dmerj (llmergesort lst)
                      (llmergesort half)) ) )) ))