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.

Computer Science & Information Technology

You might also like to view...

What can you say about the attribute type of the original product satisfaction attribute?

You are approached by the marketing director of a local company, who be- lieves that he has devised a foolproof way to measure customer satisfaction. He explains his scheme as follows: “It’s so simple that I can’t believe that no one has thought of it before. I just keep track of the number of customer complaints for each product. I read in a data mining book that counts are ratio attributes, and so, my measure of product satisfaction must be a ratio attribute. But when I rated the products based on my new customer satisfac- tion measure and showed them to my boss, he told me that I had overlooked the obvious, and that my measure was worthless. I think that he was just mad because our best-selling product had the worst satisfaction since it had the most complaints. Could you help me set him straight?”

Computer Science & Information Technology

There are two versions of the subscript operation: ____.

A. read and write B. move and write C. write and run D. read and run

Computer Science & Information Technology