CMU Artificial Intelligence Repository
Prolog 2-3 Trees Package
lang/prolog/code/ext/trees/
This package contains a set of Prolog predicates for associating
keys with values using 2-3 trees. Because 2-3 trees are used, they
automatically rebalance after each insertion or deletion.
For example,
?-
list_to_23( [ cat-dog,
hare-rabbit,
"hair"-"fur",
king-queen,
exp(1)-2.71828,
3.141593-pi
],
Tree
),
portray_23( Tree ),
put_23( 39, Tree, steps, Tree1 ),
portray_23( Tree1 ).
gives
23 Tree{
3.141593 - pi
cat - dog
hare - rabbit
king - queen
exp(1) - 2.71828
[104, 97, 105, 114] - [102, 117, 114]
}
23 Tree{
3.141593 - pi
39 - steps
cat - dog
hare - rabbit
king - queen
exp(1) - 2.71828
[104, 97, 105, 114] - [102, 117, 114]
}
There is no routine for deleting items from a tree (you can replace
them), but it would not be hard to write one.
Origin:
Email from Mark Johnson, file tree23.pl.
Version: 21-AUG-91
Ports: Edinburgh-compatible Prologs.
CD-ROM: Prime Time Freeware for AI, Issue 1-1
Author(s): Mark Johnson
Cognitive and Linguistic Sciences
Brown University, Box 1978
Providence, RI 02912
Tel: 401-863-1670
Fax: 401-863-2255
Keywords:
2-3 Trees, Authors!Johnson, Brown University, Prolog!Code,
Prolog!Extensions
References: ?
Last Web update on Mon Feb 13 10:33:38 1995
AI.Repository@cs.cmu.edu