Question: Please show me code in javascript for following question - implement a Postfix + + interpreter that can evaluate Postfix + + code line -

Please show me code in javascript for following question- implement a Postfix++ interpreter that can evaluate Postfix++ code line-by- line, as entered, for example, on a mobile device.
Postfix arithmetic
Operators, in postfix arithmetical expressions, follow operands. For example, 34+ means 3+4. The postfix expression 345+* is evaluated as follows:
345+*
39*(replace 45+ with the result of adding 4 to 5)
27(replace 39* with 27)
Postfix expressions are conveniently evaluated using a stack. An expression consisting of operands and operators (collectively,tokens), is read from left to right. Successive operands are pushed on a stack until an operator arrives. The appropriate number of operands are then popped from the stack, combined with the operator, and the result is pushed back on the stack. The result of a calculation is always to be found at the top of the stack. A stack is notated [a b c...] in the following example; the stack top is the leftmost token.
Tokens Stack before Action Stack after
345+*[] Read 3[3]
45+*[3] Read 4[43]
5+*[43] Read 5[543]
+*[543] Pop twice, evaluate, and push [93]
* Pop two twice, evaluate, and push [27]
Postfix with variables
The ++ refers to an enhanced form of postfix: a postfix with variables. Expressions can contain variable names; the value of the variable is used for the calculation. The assignment operator = assigns a value to a variable. For example
A 3=
will set the value of A to 3. It is equivalent to the infix assignment statement A =3 that is to be found in many computer languages.
Tokens Stack before Action Stack after
A 3=[] Read A [A]
3=[A] Read 3[3 A]
=[3 A] Pop twice and set the value of A to 3[]
An interactive session might proceed as follows
> A 2=[]
> B 3=[]
>A B *[6]
Symbol Table
A symbol table data structure associates keys with values. For example,
Example Key Value
Phone book Name Telephone number
DNS URL IP address
Education Student ID Module grades
Compiler Variable name Memory address
Dictionary Word Definition
A generic symbol table should support two operations, INSERT and SEARCH. There may also be a DELETE operation. No assumptions are made on the type and format of keys and values.
You will need a symbol table in your Postfix++ interpreter. The table will map variable name (key) to value.
The target hardware
A Postfix++ interpreter might run on a small device with very limited memory. This means that the variable namespace is small, for example, A-Z.
Work plan
You must consider what data structures and algorithms are required in your Postfix++ interpreter.
Phase 1: Design
Consider first your choice of data structures. Why are they appropriate? How will they be implemented? Make a list of the data structures and alongside each structure write a few words of justification.
Then consider the major algorithms. There be will algorithms to access and modify the symbol table, and an algorithm to perform postfix arithmetic. Your report will contain pseudocode for each algorithm.
Phase 2: Implementation
You can use any language you wish. Javascript or C++ are good choices.
You must write your own data structures and algorithms. The only language structure you can use is the array. Marks will be awarded for the extent of relevant original code.
You should implement at least the four arithmetical operators +,-,*,/.
Phase 3: The report
Your report should contain the following sections
Section 1 The essence of your solution to the challenge in a single paragraph.
Section 2 An explanation of the original algorithms of your solution in non-technical language. You do not need to describe the workings of any standard algorithm that might comprise part of your solution.
Section 3 Pseudocode for each original algorithm. You are urged to follow the pseudocode conventions of Cormen at al, Chapter 2. Pay great attention to how you lay out your pseudocode. In particular, take care to use structured indentation. Pseudocode that is not correctly indented, or is otherwise unreadable, will not be marked.
Section 4 A list of the data structures in your solution. Explain why each chosen data structure is suitable for the task.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!