Manual transformation of infix and prefix and suffix

Source: Internet
Author: User

Suffix:

 

That is, the reverse Polish style.

 

The inverse Polish formula is a method of expression invented by Lukasiewicz, a Polish logologist. In this way, operators are written after the operation object. For example, A + B is written as AB +, which is also called a suffix. The advantage of this notation is that it is calculated based on the sequence of operation objects and operators, without the need to use parentheses, It is also easy to evaluate using machinery. For the expression X: = (a + B) * (C + D), the suffix is XAB + CD + *: =.

 

1.1 suffix (prefix) to infix

For example, if you want to convert the suffix AB * CDE/-f * + into an infix

Search for the operator from left to right. If you find the operator, combine the symbol with the first two numbers and use a loop.

 

1.2 infix to suffix (prefix)

For example, convert the infix A * (B * (C + D/E)-f) to a suffix.

Add brackets to all operation units according to the operator priority. Then, move the symbols in the brackets to the corresponding brackets and remove the brackets. BTW, this painting method has never been used by others and belongs to the original category. It is accidental if it is similar. In addition, if you only have a black pencil, consider parentheses and square brackets.

At this point, the points for such questions in the soft exam should be able to be scored.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.