CSCI 2720 Data Structures (Spring 2009)

Programming Project #1 (Due Tuesday February 10, 2009)

This project is to implement abstract data types Stack and Queue using C++ classes and to apply the abstract data types to the evaluation of arithmetic expressions.

Requirements:

  1. Specification of abstract data types: The definitions of abstract data types Stack and Queue are specified in Chapter 3, which include the basic logical structures of a stack and of a queue and abstract operations on them.

  2. Implementation of abstract data types: Both Stack and Queue should be defined as classes. The representation of a stack consists of length (the length of the stack) and elements (contains all elements of the stack). The representation of a queue is similar. The physical storage for the elements of a stack is contiguous. However, linked memory is required for the storage of elements of a queue. Associated operations as specified are defined as public member functions of the classes. All other functions and variables for these classes should be defined as private.

  3. Algorithm for arithmetic expression evaluation: An infix arithmetic expression consists of non-negative integers and operators "+, -, *" only. E.g., 32 + 4 * 15 - 16. The evaluation of such an expression can be done in two steps:

  4. Implementation of the algorithm: The code for the algorithm should consist of a main function and at least four other functions as follows:

    1. Read that reads from a text file an infix expression into a queue and returns the queue.

    2. Transform that transforms an infix expression in a queue to the corresponding postfix expression in another queue and returns the second queue.

    3. Evaluate that evaluates a postfix expression in a queue and returns the result.

    4. Display that can displays on the standard output the content of a queue. This function allows to see a transformed postfix expression.

    The main function should be able to repeatedly call the above functions in such an order that all infix expressions in a text file can be evaluated one after another.

  5. Other details: Only operations defined for Stack and Queue are allowed to use in access to stacks and queues. No global variables are allowed.

  6. Documentations: All classes and functions must be well-documented. Indentations are also necessary for each introduced block in the code.

  7. Electronic submission: Make a subdirectory named cs2720proj1 under your home directory on odin.cs.uga.edu and place the source code file(s) in it. Also include a Makefile if your program consists of more than one source code files. Include a README text file to show your name, project number, date, and the nature of this project. Make sure that do not include any object code files or data files unless being instructed to do so.

    Log on to odin, in your home directory execute the command

      "submit cs2720proj1 cs2720"

  8. Grading policy: Requirements 1-2: 45%, 3-4: 40%, and 5-6: 15%.

  9. Extra points: 20% for the work of evaluating expressions that contain parentheses such as ( 15 + 6 ) * 7 - ( 8 * ( 34 - 2 ) ). You can discuss algorithm ideas with the instructor for this kind of expressions.