Skip to content

Instantly share code, notes, and snippets.

@grauwoelfchen
Created June 12, 2013 18:45
Show Gist options
  • Save grauwoelfchen/5767977 to your computer and use it in GitHub Desktop.
Save grauwoelfchen/5767977 to your computer and use it in GitHub Desktop.
(define t-size
(lambda (t)
(if (t-empty? t)
0
(+ 1
(t-size (t-left t))
(t-size (t-right t)))) ))
(define t-size-r
(lambda (t)
(let aux ([t t] [res 0])
(if (t-empty? t)
res
(aux (t-right t) (aux (t-left t) (+ res 1))))) ))
(printf "size : ~s~n" (t-size my-tree))
(printf "size : ~s~n" (t-size-r my-tree))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment