queue - Breadth First Binary Tree Traversal in Scheme -


I'm trying to implement a quarter tree level. I am very close, but I did not know how to get a duplicate. Any kind of help is highly appreciated. Thanks in advance. JR

  (define (atom? X) (not (pair? X)); work to manipulate a binary tree (define (leaf? Node)) (atom) node) ( Defined (left node) (cadre node) (defined) (right node) (CDADR node) (defined (label node) (if (lead node) node (car node));; First row width (defined width (node) (Q 'nQ! Node);; Encounted tree (Output' annex! (Label node);; Output root (helper node) (output 'Q-> list);; Output Elements in (Define (Auxiliary node) (if (not (Q 'empty?));; If the queue is not empty (start (if (not (leaf? Node)) (start (q' enque! ( Left node;) Left tree Q (Output enc! (Labels (left node);; Left tree (Q 'nuke!) Output Root; Enqueue right tree Q (output n); (Node);;; true root production of the tree;) (helper (Q 'deq!) ;; first element in dukes q ;; Again calls the assistant) (define (queue) ((front '()) (back' ())) (lambda (msg. obj) (cond ((eq? Message 'empty?) (Empty) ?) ((Eq? Mess' enqueue!) (If (empty? In front (Set! Obvious Ob) (Start (Set-CDR! Back Obje) (Set Obji)!)) ((Eq? Message 'dequeue!) (Start (((Val (Car Front) ) (Define q (make-queue)) (define output) (set) front (cdr front))) () ((eq? Msg 'queue- & gt; list) front)))) -Katar) (Define Tree (A (BCD) (E (FGH) I))) ------------------------- - Welcome to DrScheme, Version 4.2.2 [3M] ------------------------------ Language: R5 RS; Memory Limit: 128 MB & Gt; (Width Tree) (A B B B F D F FG GHG) ;; Should be (a BECDFIGH) & gt;  

Since it is a homework, I just give a hint: assistant < / Code> Do not take any arguments.


Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

php - Multiple Select with Explode: only returns the word "Array" -

php - jQuery AJAX Post not working -