Sunday, December 21, 2008

Valid and Equal Binary Tree Scheme

This is one possible way of determining whether two binary trees are equal. Granted this implementation is dependent on them being valid. Which is that they are both symmetric around the top head node.

(define (valid-bintree? t)
(if (null? t)
#t
(if (list? t)
(if (valid-bintree? (car t))
(if (valid-bintree? (caddr t))
#t
#f)
#f)
#f)
))

(define (equal-bintrees? a b)
(if (null? a)
(if (null? b)
#t
#f)
(if (null? b)
#f
(if (and (valid-bintree? a) (valid-bintree? b))
(and (= (cadr a) (cadr b)) (equal-bintrees?(car a) (car b)) (equal-bintrees?(caddr a) (caddr b)))
#f)
)
))

3 comments:

kaikeaponadahms said...

Casino of the Month, November 2021 - Mapyro
Explore our list of the top casinos of the month, focusing on your 김천 출장샵 casino 서울특별 출장마사지 play experience. Find 계룡 출장마사지 the best casinos 삼척 출장샵 for your game day 의왕 출장마사지 of play here.

idunquiggle said...

gold oxide - Titanium Price Per ounce | Teton Goods
Gold-Oriental Art is used for paint and babyliss pro nano titanium curling iron paint in titanium chloride a very titanium gold unique way. Use it in painting and painting titanium wedding bands applications. titanium blue

seyto said...

s147g4dhfke878 sex toys,vibrators,sex toys,cheap sex toys,dog dildo,women sex toys,wholesale sex toys,fantasy toys,wolf dildo e405d9fnouq196