Reference no: EM131052566
Algorithm To Evaluate Expressions Using Prefix Notation.
Initialization:
1. Read a token from the input stream.
a. If it is an operand, push it into the operand stack.
b. If it is an operator, push a marker onto operand stack and push the actual operator onto operator stack.
Loop While (there are more input tokens):
1. Read a token.
2. If token is an operator, push operator onto operator stack and push the marker onto operand stack.
3. Else if, the token is an operand, check the top of the operand stack for a marker.
a. If the marker is on top of the stack, push the read operand onto the operand stack.
b. Else If - the top of the operand stack contains another operand:
Loop While (the top of the stack is an operand):
1. Pop operand from operand stack.
2. Pop marker from operand stack and the corresponding operator from the operator stack.
3. Apply the operation on the read token and popped operand and obtain result.
4. 1 If the top of the stack is another operand, continue Looping (as stated above in Loop While constraint).
4.2 Else if the top of the stack is an operator or the operand stack is empty, push the result and exit the loop.
4. Go back to step 1 (loop)
Loop is finished:
When the loop is finished (all of the input has been read), the value on top of the operand stack is the result of evaluating an expression using the prefix notation.
Some possible errors:
The operand stack was not empty at the end of algorithm.
The operator stack was not empty at the end of algorithm.
An operator is the last token in the input.
Reading illegal token from the input.
Depreciation for income tax purposes
: To determine the amount to be used for depreciation for income tax purposes the owner used the assessment figures as a basis for his calculations. Which of the following most nearly reflects the depreciable amount? Show your work.
|
Income statement that reduces equity via retained earnings
: Why do capital expenditures increase assets while other cash outflows, like paying salary, taxes, etc., do not create any asset, and instead instantly create an expense on the income statement that reduces equity via retained earnings? Explain in ..
|
Expense-liabilities-revenue-net assets and assets
: Transactions and financial statements (accrual basis) for the month of December 2014. Using only five accounts – Expense, Liabilities, Revenue, Net assets and Assets – record the following transactions and prepare a balance sheet and statement of ope..
|
How nats rebellion affect relation between north and south
: How did Nat's rebellion affect the relationship between the North and South? Think about what happened to the trust between them.
|
Algorithm to evaluate expressions using prefix notation
: Algorithm To Evaluate Expressions Using Prefix Notation. Initialization: Read a token from the input stream. If it is an operand, push it into the operand stack. If it is an operator, push a marker onto operand stack and push the actual operator onto..
|
Describe the economy of your state
: What explanations have been offered in the press? How accurate are they?
|
German stock traded on the frankfurt exchange
: Erin McQueen purchased 50 shares of BMW, a German stock traded on the Frankfurt Exchange, for 64.5 euros (€) per share exactly 1 year ago when the exchange rate was 0.67 €/US$. Today the stock is trading at 71.8 (€) per share, and the exchange rate i..
|
Infrastructure overhead of implementing strategy process
: Why do many organizations choose not implement this process? Do you believe the cost and infrastructure overhead of implementing the Orion Strategy Process is worth the benefits? Why or why not? Without performing all of the steps within the Orion St..
|
Requirements of the hazard communication standard
: List and briefly discuss four exceptions to the Safety Data Sheet (SDS) requirements of the Hazard Communication Standard (HCS).
|