CS 2401 Assignment #9

Due Date: Sunday, November 1, 2009.

Objective: The goal of this assignment is to practice stacks and queues.

Assignment: Write the following three programs.

  1. Write a program that uses a stack to reverse a given string.
  2. Write a program that uses a stack to check whether a given expression has matching parentheses of three types: ( ), [ ], and { }. Hint: similar to the case of a single parenthesis, we only pop a symbol when a matching symbol appears in the string.
  3. Write a program that uses a queue to simulate a line of students waiting to be served. Enable the user of your method to indicate when a new student is coming (and insert the name of the new student), and when the student in front of the line is served (so he is no longer in the line). At any given moment, the user should also be able to print the list of all the students who are currently waiting in the line.