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
marianne needs to create a version of her slide presentation that does not include all the slides and will be used for a particu
Art [367]

Answer:

Marianne needs to create a version of her slide presentation that does not include all the slides and will be used for a particular audience. What is the best way for her to achieve this? A.) Use the Custom Show dialog box to create a new custom show

4 0
2 years ago
How do you interpret field in contest of a DBMS?
son4ous [18]
A Field is interpreted as table in DBMS.  Field is the smallest data element in a table, such as first name, last name, address, or phone number.  A database table can be thought of as consisting of rows and columns or fields.  <span>Each table has a set of fields, which define the nature of the data stored in the table.</span>
8 0
3 years ago
A signal has a wavelength of 1 11m in air. How far can the front of the wave travel during 1000 periods?
olchik [2.2K]

Answer:

A signal has a wavelength of 1 μm in air

Explanation:

looked it up

6 0
2 years ago
You suspect a component in a computer is fried. You remove any unnecessary hardware devices one by one to narrow down where the
tankabanditka [31]

The examination phase

Further Explanation:

Hardware troubleshooting in computers requires a systematic and logical approach. Taking a logical approach helps you identify the root cause much easily. Ask yourself those questions first before getting to the bottom of anything. You will find it helpful to reproduce the problem and develop a hypothesis of the problem if you ask yourself those 20 questions.

Next comes the examination phase. Having gathered everything, I will now attempt a fix based on what I think I found. In my case, I suspect that there a component in my computer that is fried. A few ways to tell if my motherboard or components attached to the motherboard are fried is to remove the side panel first and examine the circuitry before removing any unnecessary hardware devices. Obvious sings will be smell of smoke. Examine the capacitors as well. Burnt capacitors have rounded tops. This is a clear indication that they are blown.

I will now remove every single component one by one from the motherboard and test my hardware on a low-level.

Learn more about computer hardware troubleshooting

brainly.com/question/12704715

brainly.com/question/13182488

#LearnWithBrainly

8 0
3 years ago
Which of the following transferable skills are generally the most look for in the it <br> field
kherson [118]

Answer:

mechanical, encryptions, communication, network admin, leadership, and teambuilding

Explanation:

6 0
2 years ago
Other questions:
  • "Dean wants a quick way to look up staff members by their Staff ID. In cell Q3, nest the existing VLOOKUP function in an IFERROR
    10·1 answer
  • You know a Linux command will perform a desired function for you, but you cannot remember the full name of the command. You do r
    14·1 answer
  • What are five features of word 2016 you would use to capture the attention of the target audience? Defend you decisions
    9·1 answer
  • a one-two paragraph summary on the Running Queries and Reports tutorials. Apply critical thinking and an academic writing style
    6·1 answer
  • Several days a week, usually between 8:00 a.m. and 9:00 a.m., users complain of MWI problems. Some have new messages, but their
    11·1 answer
  • Although you can use a dialog box to indent paragraphs, word provides a quicker way through the ____.
    7·1 answer
  • ________type of website is an interactive website kept constantly updated and relevant to the needs of its customers using a dat
    5·1 answer
  • Ann wants to save her presentation so she can work on it later. Which device on her computer can store this data long term?
    15·2 answers
  • What is the volume of a rectangular prism with a length of 812 centimeters, width of 913 centimeters, and a height of 1225 centi
    12·1 answer
  • you are asked to create a four-digit code using the numbers from 1 to 9. how many possible codes are there--assuming that number
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!