mit-scheme-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[MIT-Scheme-devel] Complexity


From: johngalt
Subject: [MIT-Scheme-devel] Complexity
Date: Tue, 22 Dec 2009 12:37:29 -0800 (PST)

Hi,
I wrote the nwxt codes:

(define (prefix k lst)
  (cond ( (= k 0) '())
         ( (null? lst) '())
     (else (cons (car lst) (prefix (- k 1) (cdr lst))))))

(define (runs k lst)
  (let ((p (prefix k lst)))
    (if (> k (length p)) '()
        (cons  p (runs k (cdr lst))))))

-------------



(define (accumulate op initial sequence)
  (if (null? sequence)
      initial
      (op (car sequence)
          (accumulate op initial (cdr sequence)))))

(define (accumulate-runs k op init lst)
   (map (lambda (x) (accumulate op init x))
    (runs k lst)))
----------------





I'm not very familiar with this subject, so I need to ask. What is the
complexity of the two codes above?
Thanks for any kind of help.
-- 
View this message in context: 
http://old.nabble.com/Complexity-tp26893993p26893993.html
Sent from the Gnu - MIT Scheme - Dev mailing list archive at Nabble.com.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]