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
labwork [276]
3 years ago
9

Convert infix to postfix

Computers and Technology
1 answer:
kvv77 [185]3 years ago
4 0

Answer:

static int checkSymbol(char ch)

{

switch (ch)

{

case '+':

case '-':

return 1;

case '*':

case '/':

return 2;

case '^':

return 3;

}

return -1;

}

static String convertInfixToPostfix(String expression)

{

String calculation = new String("");

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

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

 

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

{

char c = expression.charAt(i);

if (Character.isLetterOrDigit(c))

operands.push(c);

else if (c == '(')

operators.push(c);

 

else if (c == ')')

{

while (!operators.isEmpty() && operators.peek() != '(')

operands.push(operators.pop());

 

if (!operators.isEmpty() && operators.peek() != '(')

return NULL;    

else

operators.pop();

}

else

{

while (!operators.isEmpty() && checkSymbol(c) <= checkSymbol(operators.peek()))

operands.push(operators.pop());

operators.push(c);

}

}

while (!operators.isEmpty())

operands.push(operators.pop());

while (!operands.isEmpty())

calculation+=operands.pop();

calculation=calculation.reverse();

return calculation;

}

Explanation:

  • Create the checkSymbol function to see what symbol is being passed to the stack.
  • Create the convertInfixToPostfix function that keeps track of the operands and the operators stack.
  • Use conditional statements to check whether the character being passed is a letter, digit, symbol or a bracket.
  • While the operators is  not empty, keep pushing the character to the operators stack.
  • At last reverse and return the calculation which has all the results.
You might be interested in
Describe how learning can be accessed in your class?​
SpyIntel [72]

There are four main learning styles used in classrooms today: Visual, auditory, reading/writing, and kinesthetic.

8 0
3 years ago
Which of the following BEST describes a permissive software license?
Olegator [25]

Answer:

B

Explanation:

A permissive software license is a free-software license which carries a minimal restrictions on how the software can be used, modified, and redistributed, usually including a warranty disclaimer.

I hope this helps.

Please rate me brainliest.

8 0
2 years ago
Legal counsel has notified the information security manager of a legal matter that will require the preservation of electronic r
Ray Of Light [21]

Answer: (B) Legal hold

Explanation:

As being a security director, the security director are approached to solidify a server that run the red hat enterprise server the 5.5.

The servers are being utilized as DNS (Dynamic host service) and the server time. This is not utilized as the database, print server and the web server. There is no particular remote associations with the server.

The window of the command will be given the root accessing. Then, it provide the associated by means of a protected shell with the access root in the system.

 

3 0
3 years ago
When you use the Copy and Paste commands, you are accessing...?
vampirchik [111]
C!!!!!!!!!!!!!!!!!!!
3 0
3 years ago
Read 2 more answers
Con respecto a la bicicleta y a la escuela, identifique un sistema​
dimulka [17.4K]

Answer:

Cycling, also called bicycling or biking, is the use of bicycles for transport, recreation, exercise or sport.[1] People engaged in cycling are referred to as "cyclists",[2] "bicyclists",[3] or "bikers".[4] Apart from two-wheeled bicycles, "cycling" also includes the riding of unicycles, tricycles, quadricycles, recumbent and similar human-powered vehicles (HPVs).

Cyclists in the 2009 Tro-Bro Léon race.

Police cyclists in London.

A woman cycling in Sri Lanka.

A bike lane in Amsterdam. Bike lanes are dedicated for cyclists and provide shelter from vehicle traffic.

Bicycles were introduced in the 19th century and now number approximately one billion worldwide.[5] They are the principal means of transportation in many parts of the world.

Cycling is widely regarded as an effective and efficient mode of transportation[6][7] optimal for short to moderate distances.

Bicycles provide numerous possible benefits in comparison with motor vehicles, including the sustained physical exercise involved in cycling, easier parking, increased maneuverability, and access to roads, bike paths and rural trails. Cycling also offers a reduced consumption of fossil fuels, less air or noise pollution, reduced greenhouse gas emissions,[8] and greatly reduced traffic congestion.[9] These have a lower financial cost for users as well as for society at large (negligible damage to roads, less road area required). By fitting bicycle racks on the front of buses, transit agencies can significantly increase the areas they can serve.[10]

In addition, cycling provides a variety of health benefits. The World Health Organization (WHO) states that cycling can reduce the risk of cancers, heart disease, and diabetes that are prevalent in sedentary lifestyles.[11][12] Cycling on stationary bikes have also been used as part of rehabilitation for lower limb injuries, particularly after hip surgery.[13] Individuals who cycle regularly have also reported mental health improvements, including less perceived stress and better vitality.[14]

Among the disadvantages of cycling are the requirement of bicycles (excepting tricycles or quadricycles) to be balanced by the rider in order to remain upright, the reduced protection in crashes in comparison to motor vehicles,[15] often longer travel time (except in densely populated areas), vulnerability to weather conditions, difficulty in transporting passengers, and the fact that a basic level of fitness is required for cycling moderate to long distances.

6 0
3 years ago
Other questions:
  • Which of these is an on-site metric for social media marketing?
    13·1 answer
  • While in slide show mode, if you are not careful you can close the application by clicking the x on the menu bar. question 38 op
    12·2 answers
  • Which of the operating systems listed below is not proprietary?
    8·1 answer
  • Select the correct answer.
    6·1 answer
  • Using either a UNIX or a Linux system, write a C program that forks a child process that ultimately becomes a zombie process. Th
    8·1 answer
  • In 1988, Robert Morris, Jr. launched a program called the _________ that used weaknesses in e-mail programs and operating system
    5·1 answer
  • Does anyone have discord
    14·2 answers
  • Which of these is most likely to contribute to the long term of a local ecosystem?
    5·1 answer
  • You want to add a caption to a table. which tab contains this option?.
    11·1 answer
  • 8) how many nanoseconds does it take for a computer to perform one calculation if it performs 6.7 x 107 calculations per second?
    6·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!