more formatting
This commit is contained in:
parent
a0420c2879
commit
9dca563e41
2 changed files with 11 additions and 32 deletions
|
|
@ -2,4 +2,8 @@
|
|||
|
||||
(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
|
||||
(define-struct node (value color left right))
|
||||
|
||||
(define (rotate-left node) (make-node
|
||||
(node-value (node-right node))
|
||||
(node-color (node-right))
|
||||
(make-node
|
||||
)
|
||||
(node-right (node-right node))
|
||||
(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
|
||||
[]
|
||||
[]))
|
||||
(define (search node value)
|
||||
(cond
|
||||
[(= (node-value node) value) node]
|
||||
[(empty? node) empty]
|
||||
[(> (node-value node) value) (search (node-left node) value)]
|
||||
[else (search (node-right node) value)]))
|
||||
Loading…
Add table
Add a link
Reference in a new issue