Chinaunix首页 | 论坛 | 博客
  • 博客访问: 220933
  • 博文数量: 136
  • 博客积分: 2919
  • 博客等级: 少校
  • 技术积分: 1299
  • 用 户 组: 普通用户
  • 注册时间: 2011-03-11 09:08
文章分类

全部博文(136)

文章存档

2013年(1)

2011年(135)

我的朋友

分类: LINUX

2011-11-18 11:20:32

  1. ;; mht created on Nov 17, 2011

  2. ;; data definition :
  3. (define-struct node (ssn name left right))
  4. ;; A binary-tree (short : BT) is either
  5. ;; 1. false; or
  6. ;; 2. (make-node soc pn lft rgt)
  7. ;; shere soc is a number, pn js a symbol, and lft and rgt are BTs.

  8. ;; A binary-search-tree (short: BST) is a BT:
  9. ;; 1. false is always a BST;
  10. ;; 2. (make-node soc pn lft rgt) is a BST if
  11. ;; a. lft and rgt are BSTs;
  12. ;; b. all ssn numbers in lft are smaller than soc, and
  13. ;; c. all ssn numbers in rgt are larger than soc.

  14. ;; examples
  15. ;(make-node 15 'd false (make-node 24 'i false false))

  16. ;; Draw a tree:
  17. (define treeA
  18.   (make-node 63 'a
  19.            (make-node 29 'b
  20.                       (make-node 15 'c
  21.                                  (make-node 10 'd false false)
  22.                                  (make-node 24 'e false false))
  23.                       false)
  24.            (make-node 89 'f
  25.                       (make-node 77 'g false false)
  26.                       (make-node 95 'h false
  27.                                  (make-node 99
阅读(400) | 评论(0) | 转发(0) |
0

上一篇:exam14.2.3

下一篇:exam14.2.5

给主人留下些什么吧!~~