@Dave solution is perfect. I prefer it over mind.
However, here is an alternate solution.
We know that this is an equation in 'x' with a degree of 1. It means it is
a straight line and root is guaranteed unless of course the equation is of
the form y = c. That is not the case here as it would m
I like that solution better than the one I suggested.
Don
On Apr 4, 4:45 pm, Dave wrote:
> @Kumar0746: Technically, you can't solve an _expression_; you can solve an
> _equation_, which is a statement of the form expression = expression, which
> is what you have.
>
> Don's suggestion is a good on
@Kumar0746: Technically, you can't solve an _expression_; you can solve an
_equation_, which is a statement of the form expression = expression, which
is what you have.
Don's suggestion is a good one. Another way is to call the expression on
the left side of the equation f(x) and the expressi
I meant postfix, of course.
Don
On Apr 4, 10:32 am, Don wrote:
> Use a backtracking search to build a prefix expression. If there are
> two more operands than operators in the expression, the next item
> could be either an operand or an operator. Otherwise, it must be an
> operand.
>
> In very lo
Simplify the expression by evaluating expressions inside parenthesis
first. Follow the order of evaluation, doing multiplications first and
then addition and subtraction. It should be possible to reduce any
expression to the form
ax+b=0. Then x=-b/a.
Don
On Apr 4, 11:18 am, arun kumar wrote:
> Gi
Given an expression in the form of a string, solve for x. The highest power
of x in the expression will be equal to 1. Operators allowed are +, * and
-. These are all binary operators. So, 2x would be written as 2*x. Every
operator will be followed by a single term or a constant.
For example, cons
Use a backtracking search to build a prefix expression. If there are
two more operands than operators in the expression, the next item
could be either an operand or an operator. Otherwise, it must be an
operand.
In very loose pseudocode:
search(int target, list operands, stack opStack, string exp