Spring 2006 CSIE 922 U0110, Programming Assignment #1

Assigned Mar 7, 2006
Due Date Mar 20, 2006  by 24:00PM

1.
lConstruct the Cartesian tree of an array A of integers.
Definition of Cartesian tree of an array: The root of a Cartesian tree contains the index of the element which is the maximum of all the entries in the array.

The left and right children of the root are the roots of recursively constructed Cartesian trees of the left and right subarrays respectively.

2.
Minimum Requirements:
3.
Your program should be written in C/C++ using object classes available in the library or new objects developed on your own. Documentation of your code is necessary.  In addition to the running code, you must include the pseudo-code, and give the timing analysis of your algorithm. Note that the brute force algorithm is not allowed.

4.
Any effort that is beyond the minimum requirement will be recorded for extra credit consideration at the end of this semester. For instance, use the Cartesian tree to solve the least common ancestor (LCA) problem of any two nodes of Cart(y1, y2, ..., yn), where the input to the LCA problem is a pair of integers, representing the indices of the array.