The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Jul 2017 |
| Last Sign in: | 304 Weeks Ago, 6 Days Ago |
| Questions Answered: | 15833 |
| Tutorials Posted: | 15827 |
MBA,PHD, Juris Doctor
Strayer,Devery,Harvard University
Mar-1995 - Mar-2002
Manager Planning
WalMart
Mar-2001 - Feb-2009
Please Answer correctly this question the balanced class which must complete is attached bellow. balanced file is
Â
A stack is a data structure where data is accessed using the LIFO (last in first out) principle. In this problem, use a stack to check whether a string has balanced parentheses (, ) and brackets {, }, [, ], or not.
A string that has balanced parentheses and brackets will be said to be balanced. Any character that is not one of (, ), [, ], {, or } is not important when deciding if a string is balanced and can be ignored.
We will define balanced as follows. A string str is balanced
You will complete the provided Balanced class that has two static methods isBalanced(String) and numberOfBalancedStrings(String[]).
Your isBalanced method must use the java.util.Stack class (in a way that solves the problem) to receive any grades for this problem.
http://docs.oracle.com/javase/8/docs/api/java/util/Stack.html
Â
Examples
The following strings have balanced parentheses
The following strings do not have balances parentheses
The following strings have balanced parentheses and brackets
The following strings do not have balanced parentheses and brackets
Note: You will receive partial marks if you code only works for parentheses (and not brackets).
----------- Â ----------- H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly