Answered step by step
Verified Expert Solution
Link Copied!

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 { ArrayList array; 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 } }

image text in transcribed

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David M. Kroenke, David J. Auer

7th edition

133544621, 133544626, 0-13-354462-1, 978-0133544626

More Books

Students also viewed these Databases questions

Question

What is the slope of the line?

Answered: 1 week ago