Jump to content

  • Log In with Google      Sign In   
  • Create Account


#Actualwarnexus

Posted 30 April 2013 - 08:31 AM

This is one expression from the first line of the file. 

 

- + + 4.0 - / - 22.0 2.0 5.0 * 3.0 4.0 7.0 / 6.0 3.0

 

The problem lies I do not understand where do these operands and numbers get stored to construct a expression tree during the time the above expression gets parsed. After constructing an expression tree, the tree is suppose to be able to output  preorder,inorder and postorder expression of that tree.

 

From the example given, the operands are connected by an operator, but the example does not help guide me in terms of how to lay the operands and numbers out for this expression.

 

I tried using a stack diagram to visualize the design of my program better but I am stuck when 22.0 appears on the stack. What is suppose to happen when 22.0 appears on the stack?

 

stack_zps213b2cb1.png


#3warnexus

Posted 30 April 2013 - 08:30 AM

This is one expression from the first line of the file. 

 

- + + 4.0 - / - 22.0 2.0 5.0 * 3.0 4.0 7.0 / 6.0 3.0

 

The problem lies I do not understand where do these operands and numbers get stored to construct a expression tree during the time the above expression gets parsed. After constructing an expression tree, the tree is suppose to be able to output  preorder,inorder and postorder expression of that tree.

 

From the example given, the operands are connected by an operator, but the example does not help guide me in terms of how to lay the operands and numbers out for this expression.

 

I tried using a stack diagram to see visualize the simulation and program better but I am stuck when 22.0 appears on the stack. What is suppose to happen when 22.0 appears on the stack?

 

stack_zps213b2cb1.png


#2warnexus

Posted 30 April 2013 - 08:07 AM

This is one expression from the first line of the file. 

 

- + + 4.0 - / - 22.0 2.0 5.0 * 3.0 4.0 7.0 / 6.0 3.0

 

The problem lies I do not understand where do these operands and numbers get stored to construct a expression tree during the time the above expression gets parsed. After constructing an expression tree, the tree is suppose to be able to output  preorder,inorder and postorder expression of that tree.

 

From the example given, the operands are connected by an operator, but the example does not help guide me in terms of how to lay the operands and numbers out for this expression.

 

Do I store the whole expression in a stack and push/pop the elements?


#1warnexus

Posted 30 April 2013 - 08:00 AM

This is one expression from the first line of the file. 

 

- + + 4.0 - / - 22.0 2.0 5.0 * 3.0 4.0 7.0 / 6.0 3.0

 

The problem lies I do not understand where do these operands and numbers get stored to construct a expression tree during the time the above expression gets parsed. After constructing an expression tree, the tree is suppose to be able to output  preorder,inorder and postorder expression of that tree.

 

From the example given, the operands are connected by an operator, but the example does not help guide me in terms of how to lay the operands and numbers out for this expression.

 

 


PARTNERS