-
-
Save viksit/aa0a0095fe386f490b6f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn queue [& xs] | |
(when (seq xs) | |
(apply conj clojure.lang.PersistentQueue/EMPTY xs))) | |
(defn level-order [rootnode] | |
(loop [curlevel (queue rootnode)] | |
(when-not (empty? curlevel) | |
(if-let [n (first curlevel)] | |
(do | |
(prn (peek curlevel)) | |
(prn (n :value)) | |
(recur (conj (pop curlevel) (n :left) (n :right)))) | |
(recur (pop curlevel)))))) | |
(level-order mytree) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment