QUESTION

DONT USE INBUILT STACK CLASSES

1. (15 points) Create an ADT stack. Using that write a program that converts an infix expression to a postfix expression and evaluates it. For simplicity, consider the operators + , - , * , / , % only.

2.

(5 points) The section “Recognizing Strings in a Language” describes a recognition algorithm for the language:

L= {w$w’:w is a possibly empty string of characters other than $,w’= reverse(w) }

In a main class named StringRecognizer, implement the String recognition algorithm shown on using the ADT Stack. The main class should prompt the user for a String, then use the stack to determine and display a message indicating whether that String is in the language or not.

3. (10 points) Implement the balanced parentheses algorithm using ADT stack. Assume that { , ( are the only parentheses allowed.

Public Answer

FDR9MN The First Answerer