Question: 1. Implement the abstract data type Stack using an array. You may use the following declaration for a static stack: Class Stack { int
1. Implement the abstract data type Stack using an array. You may use the following declaration for a static stack: Class Stack { int capacity; int topOfStack; int[] array; } 2. Implement the following operations: CreateStack(), PushStack(), PopStack(), Peek(), IsEmpty(), Is Full(). 3. Write a corresponding JAVA program to test your stack implementation by asking the user to continuously push and pop integer values to and from the stack, respectively. 4. Write a Java method that reads a list of integers and when user enters (-1) key prints them in reverse order. This is a very simple method that creates a stack, reads a series of numbers and pushes them onto the stack. When the user keys end of file, the program pops the stack and prints the numbers in reverse order. Similar to the 2nd Worksheet, instead of a recursive method, write a Java program which checks whether parentheses match (balanced 5. 6. Postfix notation is an unambiguous way of writing an arithmetic expression with out parentheses. It is defined so that if "(exp1)op(exp2)" is a normal fully paren- thesized expression whose operation is op, the postfix version of this is pexp1 pexp2 op", where pexp is the postfix version of exp and pexp2 is the postfix ver- sion of exp2. The postfix version of a single number or variable is just that number or variable. So, for example, the postfix version of "((5 + 2) (8 - 3))/4" is "5 2 + 8 3 * 4/". Write a java method to implement the postfix evaluation. The method should read a postfix string consisting of only multi-digit numeric data and the +, -, *, and/ operators, call the evaluation algorithm, and then print the result.
Step by Step Solution
There are 3 Steps involved in it
Heres a Java implementation for the abstract data type Stack and the specified operations as well as the methods to test the stack reverse a list of i... View full answer
Get step-by-step solutions from verified subject matter experts
