aboutsummaryrefslogtreecommitdiff
path: root/hw04_path.scm
diff options
context:
space:
mode:
Diffstat (limited to 'hw04_path.scm')
-rw-r--r--hw04_path.scm21
1 files changed, 21 insertions, 0 deletions
diff --git a/hw04_path.scm b/hw04_path.scm
new file mode 100644
index 0000000..4d404fb
--- /dev/null
+++ b/hw04_path.scm
@@ -0,0 +1,21 @@
+#lang scheme
+
+;; NAME: hw04_bintree.scm
+;; AUTHOR: Ben Burwell
+;; DESC: CSI310 - Programming Languages - Homework 4 - Binary Tree
+;; HISTORY: Created 2013-02-11
+
+(define path-helper
+ (λ (n bst pth)
+ [ (equal? (get-value bst) n) pth ]
+ [ (< n (get-value bst)) (cons 'left (path-helper n (get-left bst))) ]
+ [ (> n (get-value bst)) (cons 'right (path-helper n (get-right bst))) ]
+ ))
+
+
+(define path
+ (λ (n bst)
+ (cond
+ [ (not (tree? bst)) 'not-a-tree ]
+ [ else (path-helper n bst '()) ]
+ ))) \ No newline at end of file