Elementary Functional Trees

Trees, Binary Trees, and Binary Search Trees

CSCI C243

Version 1.0.11

Source code files:

  1. Java: BinaryTree.java, Tnode.java, Visitor.java, BinaryTreeMaker.java, TreeTest.java, (omit: Graphable.java, tmp.dot, GraphViewer.java).
  1. Haskell binary trees and general trees: BinaryTree.hs, GeneralTree.hs, GeneralTreeFCNS.hs (?), XmlTree.hs, XmlTree2.hs
  1. Haskell binary search trees: BinarySearchTree.hs, TreeSet.hs, TreeSetTest.hs

A. Java Functional Binary Trees

This is a Java implementation of binary trees, in functional style, with graphics provided by the GraphViz library.

(Not in the textbook, handout-10a.ps)

B. Haskell Trees

(src/functional/haskell)

  1. BinaryTree.hs
  2. GeneralTree.hs
  3. (skip) GeneralTreeFCNS.hs is an implementation of general trees using the first child next sibling representation. It seems more trouble than it’s worth!
  4. XmlTree.hs is an example of XML tree processing.
  5. (optional) XmlTree2.hs using a full-strength XML package (“xml” from Hackage, the module is Text.XML.Light), shows that real XML processing is a bit more complex due to namespaces and qualified names, node types other than element and text, etc.

C. Haskell Binary Search Trees

Haskell code:


  1. Revisions:
    • 1.0.1, 2016 Nov 4. Change title.
    • 1.0, 2014 Nov 10. Import content from 10-trees.txt and 11-sets.txt.