1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
wolverine [178]
3 years ago
13

Programming challenge description: Given a string comprising just of the characters (,),{,},[,] determine if it is well-formed o

r not. Input: Your program should read lines from standard input. Each line contains a string comprising of the characters mentioned above. There is no whitespace between characters. Output: Print out True if the string is well-formed, False otherwise.
Computers and Technology
1 answer:
nadezda [96]3 years ago
5 0

Answer:

Employing Java language,

Explanation:

//for using stack data structure

import java.util.Stack;

//class definition

public class BracketMatch {

   //function to find the string is well formed or not

   public static boolean isWellFormed(String str) {

       //variable to store the character value

       char ch;

       //check if the first character itself is the end of the brackets

       if (str.charAt(0) == ')'||str.charAt(0) =='}'||str.charAt(0) ==']')

           return false;

       //creating a stack of character type

       Stack<Character> stack = new Stack<Character>();

       //iterating through the characters in string

       for(int i=0; i < str.length(); i++) {

           //storing the current character from the string in the variable

           ch = str.charAt(i);

           if(ch == '('||ch=='{'||ch=='[')

               //if the character is starting of the brackets push it into stack

               stack.push(ch);

           else if(ch == ')')

               //if it is closing bracket and the stack is empty then the string is not well formatted

               if(stack.empty())

                   return false;

               else if(stack.peek() == '(')

                   stack.pop();

               else

                   return false;

           else if(ch == '}')

               if(stack.empty())

                   return false;

               else if(stack.peek() == '{')

                   stack.pop();

               else

                   return false;

       }

       //returning the stack content, if the string will be well formed the stack would be empty

       //after all the operations

       return stack.empty();

   }

   //main method

   public static void main(String[] args) {

       //calling function to find if the string is welll formatted or not

       System.out.println(isWellFormed("{}"));

       //calling function to find if the string is welll formatted or not

       System.out.println(isWellFormed("([)]"));

   }

}

You might be interested in
What does it mean by does the author create an emotional connection toward the readers?
andreyandreev [35.5K]

Answer:

the author makes an emotional connection between you and the character

Explanation:

short version:you feel the characters emotion

6 0
2 years ago
Select the characteristics of a Base Transceiver Station:
Andru [333]

Answer:

The correct answer to the following question is options A, B, and D.

Explanation:

Base Transceiver Station (BTS) is an apparatus that works wireless communication between the network and user equipment (UE - Mobile phones (handset), wireless network computers). Wireless technologies like wi-fi, GSM, CDMA, etc.

Some elements of BTS :

  • Radio base station
  • Tower/Mast
  • Duplexer
  • Transceiver unit (TRU)
  • Microwave

So the above are the elements of the BSA, then it also having the characteristics related to these elements like it definitely connects to a cell network, sends phone or mobile phone and microwave signals to cellular providers but it isn't able to send the signals to the recepients.

8 0
3 years ago
If several programs or apps are running simultaneously, your computer or device might use up its
kirill [66]

Answer: I am pretty sure it's RAM

Explanation:

I'm not 100% positive bc I haven't gotten my scores back yet but I think that's it.

7 0
3 years ago
Frequently used data is identified and read from the hard disk into memory, or _____, and is easily accessible when needed.
frutty [35]

Answer:

The answer would be disk cache.

7 0
3 years ago
Why am I constantly getting bombarded with brainly plus ads and how to fix this without paying for it?
Helga [31]

Answer:

there really is no way to fix it. I've tried everything everybody says sorry

8 0
3 years ago
Read 2 more answers
Other questions:
  • Wendy is an attacker who recently gained access to a vulnerable web server running Microsoft Windows. What command can she use t
    9·1 answer
  • _______ refers to the poitically, religiously, or ideologically motivated use of computers (or related technology) by an individ
    15·1 answer
  • Write the percentage 5 1/4 as a decimal​
    8·1 answer
  • Windows workstations all have elements of server software built-in. What are these elements, and why is the Windows Professional
    9·1 answer
  • Ad identifies and describes at least four ways to prevent downloading of spyware, adware, and viruses to computer
    9·1 answer
  • Which element can be changed using the Print pane? Check all that apply.
    9·2 answers
  • Which of the following activities does an effective team do?
    15·2 answers
  • Help plz. due yesterday
    13·1 answer
  • Enumerate the the risk in the preparation and cooking in starch and cereal dishes and other food​
    11·1 answer
  • In the year, , the American Department of Defense put a military research network, called ARPANET online.
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!