The Gateway to Computer Science Excellence
0 votes
207 views
Given an arithmetic expression involving *, + only write an object oriented code for its representation and evaluation
in Algorithm Challenges by Veteran (425k points) | 207 views
0
evaluation of expression using java ?
0
yes, Java is fine. But consider only + and *. Importance is in how well the classes are designed.
0
if - or / comes in middle then that expression will not be evaluated with this code?
0
Evaluation by stack

1> take an expression

2> Do its postfix

3> Then evaluate by + or *
0
Yes, but a bit more formal. First represent the expression in a tree. So, this tree need to be designed- how should be its nodes?
0
Each internal node corresponds to operator and each leaf node corresponds to operand .rt sir ?
0
yes like parse tree
0
@Manojk exactly. Now put them in C++/Java classes.
0

sir done here

As I cannot remember some functions of java , I took help from net

It is exactly what u want (if we remove preorder traversal part), rt?

Please log in or register to answer this question.

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
50,644 questions
56,523 answers
195,602 comments
101,282 users