Name: Anonymous 2012-11-12 16:01
If a recursive algorithm calls itself twice for each element in a set, does that mean it has n^2 complexity, or is that 2n and therefore n complexity? I am confused.
#lang racket
(define (all-pairs s)
(if (<= (length s) 1) '()
(append (map (λ(x)(cons (car s) x))
(cdr s))
(all-pairs (cdr s)))))