CS 302 Assignment 3: Using Stacks.

Due date: Tuesday, February 11, 2014, midnight.

  • All programming assignments must be submitted electronically. Submit them to the graduate assistant, Jimi Andro-Vasko, by email at
    androvas"at"unlv"dot"nevada"dot"edu
    on or before the due date. Your email must come from your university or engineering college account, and your programs must compile and run on College computers.
  • The assignment is to write four programs.
    1. Write a program which uses a stack of integer to evaluate a postfix expression. The operands will be single digit numerals, and the operations will be addition, subtraction, multiplication, and division, using the characters +, -, *, and /. Division is implemented as for integers in C++, namely using truncation.
      You must use the array implementation of stack.
    2. Write a program which uses a stack of integer to evaluate a postfix expression. The operands will be single digit numerals, and the operations will be addition, subtraction, multiplication, and division, using the characters +, -, *, and /. Division is implemented as for integers in C++, namely using truncation.
      You must use the linked list implementation of stack.
    3. Write a program that uses a stack of character to accept strings which have matching parentheses, braces, and brackets. All other symbols are to be ignored. For example, the string "xA(5*[bz]{gbn-}3cT_)" will be accepted, but the string "(a[b)xxzZ]" will not be.
      You must use the array implementation of stack.
    4. Write a program that uses a stack of character to accept strings which have matching parentheses, braces, and brackets. All other symbols are to be ignored. For example, the string "xA(5*[bz]{gbn-}3cT_)" will be accepted, but the string "(a[b)xxzZ]" will not be.
      You must use the linked list implementation of stack.
  • The input of each program will be a single line of text.
  • The output of each program must be an appropriate message. For the first two programs, the output should either be a number, or the message that the input string is erroneous. For the other two programs, the output should be simply a message stating that the input string is accepted or that it is erroneous.
  • This is a smaller assignment that it seems, because the programs will contain a large amount of common code. However, you must turn in four separate files for the four programs, and Mr. Andro-Vasko must be able to run them on the College computers using the (secret) benchmark examples.
  • A small file for the first and second programs. Each line is a separate instance.
  • A small file for the third and fourth programs. Each line is a separate instance.
  • A larger file for the first and second programs.
  • A larger file for the third and fourth programs.