
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!

Lab 4
(Stacks)
Exercise 1
Create a generic class Stack
Exercise 2
Write a method void reverse() that replace the contents of the stack with those same elements but in reversed order using two temporary stacks.
Exercise 3
Write a method boolean checkParentheses(String s) that checks that the different parenthesis (,{, [,],}, ) in the String s are balanced using the previously created Stack class.
Exercise 4
Write a method String infixToPostfix(String s) that converts an expression from the infix notation to the postfix notation using the previously created Stack class.
Exercise 5
Write a method int evaluatePostfixExp(String s) that evaluates an expression in a postfix notation using the previously created Stack class.