more formatting
This commit is contained in:
parent
a0420c2879
commit
9dca563e41
2 changed files with 11 additions and 32 deletions
|
|
@ -3,3 +3,7 @@
|
||||||
(define id (lambda (x) x))
|
(define id (lambda (x) x))
|
||||||
|
|
||||||
(define Y (lambda (f) (lambda (x) (f (x x))) (lambda (x) (f (x x)))))
|
(define Y (lambda (f) (lambda (x) (f (x x))) (lambda (x) (f (x x)))))
|
||||||
|
|
||||||
|
(define T (lambda (x) (lambda (y) x)))
|
||||||
|
|
||||||
|
(define F (lambda (x) (lambda (y) y)))
|
||||||
37
rbtree.rkt
37
rbtree.rkt
|
|
@ -1,34 +1,9 @@
|
||||||
#lang racket
|
#lang racket
|
||||||
(define-struct node (value color left right))
|
(define-struct node (value color left right))
|
||||||
|
|
||||||
(define (rotate-left node) (make-node
|
(define (search node value)
|
||||||
(node-value (node-right node))
|
(cond
|
||||||
(node-color (node-right))
|
[(= (node-value node) value) node]
|
||||||
(make-node
|
[(empty? node) empty]
|
||||||
)
|
[(> (node-value node) value) (search (node-left node) value)]
|
||||||
(node-right (node-right node))
|
[else (search (node-right node) value)]))
|
||||||
(node-parent node)))
|
|
||||||
|
|
||||||
(define (rotate-left node) (let
|
|
||||||
((a (node-left node))
|
|
||||||
(b node)
|
|
||||||
(c (node-right node))
|
|
||||||
(x (node-left a))
|
|
||||||
(y (node-right a))
|
|
||||||
(z (node-left c))
|
|
||||||
(w (node-right c)))
|
|
||||||
(
|
|
||||||
make-node
|
|
||||||
(value c)
|
|
||||||
(color c)
|
|
||||||
(make-node (value b) (color b) (make-node
|
|
||||||
(value a)
|
|
||||||
(color a)
|
|
||||||
x
|
|
||||||
y
|
|
||||||
|
|
||||||
))
|
|
||||||
|
|
||||||
(define (insert node value) (cond
|
|
||||||
[]
|
|
||||||
[]))
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue