Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

Convert infixed expression to postfix
Given that an arithmetic expression is properly form with respect to parentheses, do the following:
• Create an empty stack to hold any arithmetic operators and left parenthesis, ONLY.
• A string to contain the postfix expression - the output from this conversion.
• Scan the arithmetic expression from left to right.
• While the are more symbols in the arithmetic expression, 
{
After a symbol is scanned, there are four (4) basic rules to observed and apply accordingly:
1. If the symbol is an operand (a number), prepare it to the output string.
2. If the symbol is an operator and if the stack is empty, push the symbol on the stack. 
Otherwise, if the symbol is either '(' or ')', check for the following conditions:
If the symbol is '(', push on to the stack,
Otherwise
If the symbol is ')'
{
Pop everything from the operator stack down to the first '('. prepare each item 
popped from the stack to the output string. Do not prepare the item ')'. Discard it.
}
3. If the symbol scanned is an arithmetic operator, check for the following and apply accordingly:
If the operator on the top of the stack has higher or equal precedence, that operator is popped from off the stack, and is written to the to the output string. This process is continues until one of two things happen:
(a) Either the first '(' is encountered. When this occurs, the '(' is removed from the stack and is discarded, and the recently scanned symbol is placed on the stack

OR

(b) The operator on the stack has lower precedence than the one just scanned. When this situation arises, the recently scanned symbol is pushed onto the stack.
}
4. After the arithmetic expression is exhausted, any operator is remaining on the stack must be popped from off and is written to the output string.

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M9105836

Have any Question?


Related Questions in Computer Engineering

The freemont automobile factory has discovered that the

The Freemont Automobile Factory has discovered that the longer a worker has been on the job, the more parts the worker can produce. I need help finding an application that computes and displays a worker's anticipated out ...

Suppose pointers are 4 bytes long and keys are 12 bytes

Suppose pointers are 4 bytes long, and keys are 12 bytes long. How many keys and pointers will a block of 16,384 bytes have?

Security planfor this assignment you will write some

Security Plan For this assignment, you will write some security planning documents for the Computer Science department. There are 4 different types we will be concerned with for this project (enterprise, issue-specific, ...

Explain that the biggest problems with adware is that it

Explain that the biggest problems with adware is that it slows down the computers its running on.

Question 1 answer the questions below in order to determine

Question: 1) Answer the questions below in order to determine the best solution for user-related data storage within your organization. Explain your recommendation. Be sure to cite your sources. 1. Are there different ty ...

Question research and provide a write up on available

Question : Research and provide a write up on available routers and switches. The report should include information for at least two router and two switching devices. Included in the write-up should be a description of t ...

Remembering the pythagorean theorem - the square of the

Remembering the Pythagorean Theorem - The square of the hypotenuse is equal to the sum of the squares of the other two sides Your assignment is to design a Fortran 95 program with three solutions for the quadratic equati ...

Tell us about the starbucks corp what it does and makes

Tell us about the Starbucks Corp. what it does, and makes; publically traded or privately owned; how big, etc. 'what' is; it is exposition. Although who is the founders and history of the company; and its sense of social ...

Question what is a ipsec ssl vpn dtls dmarc pki pem ssh

Question : What is a( IPSEC, SSL , VPN, DTLS , DMARC, PKI, PEM, SSH, Kerberos, DKIM) ?. Brifley and answer the following brief. Identify the security problems How the security protocol was used to solve the problems OR e ...

Question review ram flash memory magnetic and optical

Question : Review RAM, Flash Memory, Magnetic and Optical storage technologies concerning their placement in the usage hierarchy of contemporary computer systems. Include size, speed and cost considerations at each level ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As