Design and Analysis of Algorithms

CSE 5311 Section 087/088/098 Fall 2002

Program 1

Due: September 26, 2002 (midnight)

For this assignment you will write a program to store an ISA tree which holds a set of ISA relationships, e.g., "cat ISA mammal." Your program will use the ISA tree to compute the semantic distance between two words in the tree, defined as the maximum number of branches to the closest common ancestor of the two words. Finally, your program will output the ISA tree in a nested format. The specifics of the program follow. All code must be written by you individually and may not be copied in whole or in part from other sources.

  1. Your program will first read in a specification of the problem from a file whose name is given as a command-line argument. The file will first give the word at the root of the ISA tree using the format ROOT word. Next, all the ISA relationships are given in the form ISA word1 word2, one per line, which means word1 should be a child of word2 in the ISA tree. All words are made up of the characters a-z, and you may assume that word2 will have already been stored in the tree. Finally, the word pairs for computing the semantic distance are given in the form SD word1 word2, one per line, where either or both words may not be in the ISA tree. Below is a sample input file.

    ROOT animal
    ISA mammal animal
    ISA reptile animal
    ISA dog mammal
    ISA cat mammal
    ISA ape mammal
    ISA lizard reptile
    SD dog dog
    SD dog cat
    SD dog reptile
    SD lizard snake

  2. Because a node in the ISA tree may have any number of children, your program should use the left-child, right-sibling tree data structure to store the ISA tree.

  3. After building the ISA tree, your program will output the semantic distance for each SD line. For the sample input above, the output will look like:

    SD (dog, dog) = 0
    SD (dog, cat) = 1
    SD (dog, reptile) = 2
    SD (lizard, snake) = undefined

  4. Finally, your program will print out the ISA tree in a nested format. The output for the above sample input will look like:


  5. After ensuring that your program compiles and runs correctly on the system, submit your source code to me ( by the above deadline. Please only send one email message; use attachments if sending multiple files. In addition to correct functionality and satisfaction of the above constraints, your submission will be graded based on good programming style and documentation.