Question: Please follow the instructions EXACTLY. I will leave feedback Part 2 ( 5 0 points ) : Design and implement the following functions in a

Please follow the instructions EXACTLY. I will leave feedback Part 2(50 points): Design and implement the following functions in a test program in file called
isBalanced. java:
Implement a stack data structure and using it to solve a classic problem: checking for balanced
parentheses in an expression. This assignment not only reinforces the concept of stacks but also
demonstrates how they can be used to solve practical problems like checking for balanced
parentheses in expressions.
Implement a stack data structure (15pts ):
Create a class called 'Stack' with methods for 'push', 'pop', 'isEmpty', and 'peek'.
You can choose to implement the stack using a list or an array.
Create a function 'isBalanced(expression)'(15 pts):
This function takes an input string 'expression' containing parentheses, brackets, and curly
braces.
Implement the logic to check whether the expression has balanced parentheses using the
stack you implemented in Task 1.
Return 'True' if the parentheses are balanced, and 'False' otherwise.
Test your implementation 20pts:
Write test cases to validate your 'isBalanced' function.
Include test cases with various expressions, such as '(0))','{[[]}}','()[]{','({[})', etc.
Ensure that your function handles edge cases correctly.
Test cases
print(isBalanced("(0)")) # True
print(isBalanced("{0}}")) # True
print(isBalanced("O[0{0")) # True
print(isBalanced("({[})")) # False
Please follow the instructions EXACTLY. I will

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!