











Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!












1
Corky Cartwright Department of Computer Science Rice University
(define (qsort l) (cond [(empty? l) empty] [else (local ((define pivot (first l)) (define other (rest l))) (append (qsort [filter (lambda (x) (<= x pivot)) other]) (list pivot) (qsort [filter (lambda (x) (> x pivot)) other])))]))
(define (qsort l) (cond [(empty? l) empty] [else (local ((define pivot (first l)) (define other (rest l))) (append (qsort [filter (lambda (x) (<= x pivot)) other]) (list pivot) (qsort [filter (lambda (x) (> x pivot)) other])))])) Why?
(define (generative-recursive-fun problem) (cond [(trivially-solvable? problem) (determine-solution problem)] [else (combine-solutions ... problem ... (generative-recursive-fun (generate-problem-1 problem)) … (generative-recursive-fun (generate-problem-n problem)))]))
; If we start with an interval S wide, then ; we only need a limited number of steps ; to reach an interval R wide. In particular, ; the intervals will proceed as S, S/2, S/4, ; ..., and will reach size smaller than R in ; log 2 (R/S) steps.