CSCI 2720 Data Structures (Spring 2009)

Written Assignment 1 (Due Tuesday February 17, 2009)

Choose any 3 questions out the 4 given to answer. However all the questions are within the scope of learning so you need to be able to answer all the questions.

  1. Assume the nodes in a binary tree store integer numbers. Write a recursive function that can return the maximum integer stored in the tree.

  2. Write a non-recursive function (using a stack) to traverse a binary tree in the postorder.

  3. Write a recursive function to convert an ordered tree to a binary tree according to the following rules:

    (1) for every node v, its first child becomes its left child, and
    (2) for every node v, its right sibling becomes its right child.

    The function should be written in the pseudo code (see the text) and detailed enough to describe the process, not just the rough idea.

  4. Manually build the KMPskip table for pattern p=AABAA. The alphabet contains A, B and other characters.