Assignment 4: Balanced trees and set operations

Date: xxx
Deadline:xxx

Objectives

You must implement a tree and set API and a multi-tool set manipulation program.

Requirements

You will construct the following programs that demonstrate your tree and set API:

ident
Prints out the set formed by its input file unchanged.
union
Computes the set union between two input files.
inter
Computes the set intersection between two input files.
substract
Computes the set difference between two input files.

All these programs operate on the set of unique input lines of their respective operands and prints out their output in sorted order. For example, ident forms the set of unique input lines from its input and prints them back out in sorted order.

Your implementations must achieve this by loading the input lines as nodes in an AVL tree [1], perform computation on the tree, and print out the results using an in-order traversal of the result tree.

[1]https://en.wikipedia.org/wiki/AVL_tree

You must submit your work as a tarball [2]. Next to the source code, your archive must contain a text file file named “AUTHORS” containing your name and Student ID(s).

[2]http://lmgtfy.com/?q=how+to+make+a+tarball

Additional program

For a maximum grade you must also provide an additional program calc which can compute arbitrary algebraic set expressions:

For example:

$ ./calc "a b +"
a
b

$ ./calc "a a + b + b c + *"
b

Getting started

  1. Unpack the provided source code archive; then run make.
  2. Try out the generated ident program and familiarize yourself with its interface.
  3. Read the file tree.h and understand the interface.
  4. Implement the data structure in tree.c.
  5. Implement the set union and intersection operator, then test the resulting union and intersect programs.
  6. Complete substract. Use tree node deletion to achieve this.
  7. Complete calc.

Grading

Your grade starts from 0, and the following tests determine your grade: