Develop a pseudocode algorithm to build an expression tree from a prefix expression.
Create an expressiontree stack
Create an operator stack
While there is input
```
{
get the next term
if the term is an operand
{
create a node object containing the operand
push it on the expression tree stack
}
else if the term is an operator
{
push it on the operator stack
}
}
While the operator stack is not empty
{
pop one operator from the operator stack
pop two nodes from the expression tree stack
create a new node object containing the operator and pointing to the two nodes
push the resulting node onto the expression tree stack
}
```
At the conclusion of this algorithm, there should be a single node on the expression tree stack and it will be the root of the expression tree.
You might also like to view...
If hackers wanted to record everything that you type, such as a credit card number, they could install a(n) ________
Fill in the blank(s) with correct word
_________ components can be internal (located inside a computer) or external (located outside a computer and connected to a computer via a wired or wireless connection). A. Hardware B. Software C. Data D. Instruction
Fill in the blank(s) with the appropriate word(s).
In reference to express card types (e.g. Express Card 34 and Express Card 54), which of the following BEST describes what the numbers indicate?
A. Size of the memory allocation B. Size of the expansion slot C. The IEEE specification that it originated from D. Number of available communication channels
Objects normally are not allowed to know how other objects are implemented. This is called __________.
a) encarceration b) information hiding c) blindfolding d) inheritance