Answered step by step
Verified Expert Solution
Question
1 Approved Answer
IN JAVA import java.util.*; public class OurStackExample2 { public static void main (String[] argv) { String s = ((())); checkParens (s); s = ()(())(); checkParens
IN JAVA
import java.util.*; public class OurStackExample2 { public static void main (String[] argv) { String s = "((()))"; checkParens (s); s = "()(())()"; checkParens (s); s = "((())"; checkParens (s); } static void checkParens (String inputStr) { // Extract the letters from the String into a char array. char[] letters = inputStr.toCharArray(); // Create an instance of the stack. OurStack2 stack = new OurStack2 (); boolean unbalanced = false; for (int i=0; i
import java.util.*; public class OurStack2 { ArrayListarray; int top; public OurStack2 () { // Can be unlimited in size now. array = new ArrayList (); top = 0; } public void push (char ch) { // INSERT YOUR CODE } public char pop () { // INSERT YOUR CODE } public boolean isEmpty () { // INSERT YOUR CODE } } In-Class Exercise 7: Download OurStackExample2.java and modify OurStack2.java to use an ArrayList instead of an array. This way, there's no upper limit to the size. What part of the code changes from the original ourStack.java? Do we still need to check for a lower limit in pop()
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started